github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/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/onflow/flow-go/model/flow"
    10  	"github.com/onflow/flow-go/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  }