github.com/koko1123/flow-go-1@v0.29.6/model/flow/account_test.go (about) 1 package flow_test 2 3 import ( 4 "encoding/json" 5 "testing" 6 7 "github.com/stretchr/testify/assert" 8 9 "github.com/koko1123/flow-go-1/model/flow" 10 "github.com/koko1123/flow-go-1/utils/unittest" 11 ) 12 13 func TestAccountPublicKey_MarshalJSON(t *testing.T) { 14 accountPrivateKey, err := unittest.AccountKeyDefaultFixture() 15 assert.NoError(t, err) 16 17 accountKeyA := accountPrivateKey.PublicKey(42) 18 19 encAccountKey, err := json.Marshal(&accountKeyA) 20 assert.NoError(t, err) 21 22 var accountKeyB flow.AccountPublicKey 23 24 err = json.Unmarshal(encAccountKey, &accountKeyB) 25 assert.NoError(t, err) 26 27 assert.Equal(t, accountKeyA, accountKeyB) 28 }