github.com/chain5j/chain5j-pkg@v1.0.7/crypto/icap/icap_test.go (about) 1 // Package icap 2 // 3 // @author: xwc1125 4 package icap 5 6 import ( 7 "fmt" 8 "log" 9 "strings" 10 "testing" 11 12 "github.com/chain5j/chain5j-pkg/types" 13 ) 14 15 func TestConvertAddressToICAP(t *testing.T) { 16 icap := ConvertAddressToICAP("xwc1125", "0000", types.HexToAddress("0x0000059B6D857f25fBDc1ab0Bb78AAa048f638A5")) 17 fmt.Println("icap", icap) 18 address, err := ConvertICAPToAddress("xwc1125", 4, strings.ToUpper(icap)) 19 if err != nil { 20 panic(err) 21 } 22 23 fmt.Println("address", address.Hex()) 24 25 address, err = ConvertICAPToAddress("xwc1125", 4, strings.ToLower(icap)) 26 if err != nil { 27 panic(err) 28 } 29 30 fmt.Println("address2", address.Hex()) 31 } 32 33 func TestIban(t *testing.T) { 34 banInfo, err := ToICAP(Customer{ 35 currency: "chain5j", 36 orgCode: "0000", 37 resultLen: 60, 38 customer: types.HexToHash("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").Bytes(), 39 }) 40 if err != nil { 41 panic(err) 42 } 43 customer, err := ParseICAP(*banInfo) 44 if err != nil { 45 panic(err) 46 } 47 log.Println(customer) 48 }