INNER CODE UNIT · Go
TestAccountWriteReadSignTxVerifyTx
volodymyrprokopyuk/go-blockchain · chain/account_test.go:20
func TestAccountWriteReadSignTxVerifyTx(t *testing.T) {
defer os.RemoveAll(keyStoreDir)
// Create a new account
acc, err := chain.NewAccount()
if err != nil {
t.Fatal(err)
}
// Persist the new account
err = acc.Write(keyStoreDir, []byte(ownerPass))
if err != nil {
t.Fatal(err)
}
// Re-create the persisted account
path := filepath.Join(keyStoreDir, string(acc.Address()))
acc, err = chain.ReadAccount(path, []byte(ownerPass))
if err != nil {
t.Fatal(err)
}