github.com/aeternity/aepp-sdk-go/v7@v7.0.1/account/keystore_test.go (about) 1 package account 2 3 import ( 4 "encoding/hex" 5 "fmt" 6 "testing" 7 ) 8 9 func TestWrite(t *testing.T) { 10 prv := []byte{225, 128, 98, 185, 25, 78, 104, 215, 238, 158, 73, 59, 202, 121, 33, 211, 236, 62, 1, 121, 152, 198, 219, 177, 15, 248, 248, 172, 85, 22, 105, 133, 201, 101, 152, 238, 118, 129, 16, 165, 224, 51, 1, 186, 46, 47, 63, 47, 70, 67, 232, 228, 202, 93, 46, 182, 144, 182, 8, 152, 185, 3, 23, 233} 11 // prvHex := "e18062b9194e68d7ee9e493bca7921d3ec3e017998c6dbb10ff8f8ac55166985c96598ee768110a5e03301ba2e2f3f2f4643e8e4ca5d2eb690b60898b90317e9" 12 // pub := []byte{201, 101, 152, 238, 118, 129, 16, 165, 224, 51, 1, 186, 46, 47, 63, 47, 70, 67, 232, 228, 202, 93, 46, 182, 144, 182, 8, 152, 185, 3, 23, 233} 13 // pubAdd := "ak_2XhQw1o9UwvHNFTe1vCaLEDfUQv9Y4APSVRomFgQtTjHukMbdH" 14 15 // ac, _ := New() 16 // fmt.Println(ac.SigningKey) 17 // fmt.Println(ac.SigningKeyToHexString()) 18 // fmt.Println(ac.SigningKey.Public()) 19 // fmt.Println(ac.Address) 20 21 ac, _ := loadFromPrivateKeyRaw(prv) 22 23 type args struct { 24 account *Account 25 password string 26 } 27 tests := []struct { 28 name string 29 args args 30 match bool 31 }{ 32 { 33 "one", 34 args{ac, "test"}, 35 true, 36 }, 37 } 38 for _, tt := range tests { 39 t.Run(tt.name, func(t *testing.T) { 40 encryped, err := KeystoreSeal(tt.args.account, tt.args.password) 41 if err != nil { 42 t.Errorf("Error %s", err) 43 return 44 } 45 fmt.Printf("%s", encryped) 46 decrypted, err := KeystoreOpen(encryped, tt.args.password) 47 if err != nil { 48 t.Errorf("Error %s", err) 49 return 50 } 51 a := hex.EncodeToString(decrypted.SigningKey) 52 b := hex.EncodeToString(tt.args.account.SigningKey) 53 if !tt.match && a == b { 54 t.Errorf("Wanted match but no") 55 } 56 }) 57 58 } 59 }