package wallet import "testing" func TestDecodeTronAddressRoundtrip(t *testing.T) { // Golden addresses from the test mnemonic (see derive_test.go). for _, addr := range goldenAddrs { payload, err := DecodeTronAddress(addr) if err != nil { t.Fatalf("decode %s: %v", addr, err) } if len(payload) != 21 || payload[0] != 0x41 { t.Fatalf("bad payload for %s: %x", addr, payload) } // Re-encode the payload and expect the same address back. if got := base58CheckEncode(payload); got != addr { t.Fatalf("roundtrip: %s -> %s", addr, got) } } } func TestDecodeTronAddressRejectsBad(t *testing.T) { if _, err := DecodeTronAddress("TUEZSdKsoDHQMeZwihtdoBiN46zxhGWYdX"); err == nil { t.Fatal("expected checksum failure on tampered address") } if _, err := DecodeTronAddress("not-an-address"); err == nil { t.Fatal("expected failure on garbage") } } func TestTronAddressBodyHex(t *testing.T) { body, err := TronAddressBodyHex(goldenAddrs[0]) if err != nil { t.Fatalf("body hex: %v", err) } if len(body) != 40 { // 20 bytes -> 40 hex chars t.Fatalf("body hex len %d, want 40 (%s)", len(body), body) } }