github.com/iotexproject/iotex-core@v1.14.1-rc1/action/protocol/poll/blockmeta_test.go (about) 1 // Copyright (c) 2019 IoTeX Foundation 2 // This source code is provided 'as is' and no warranties are given as to title or non-infringement, merchantability 3 // or fitness for purpose and, to the extent permitted by law, all liability for your use of the code is disclaimed. 4 // This source code is governed by Apache License 2.0 that can be found in the LICENSE file. 5 6 package poll 7 8 import ( 9 "testing" 10 11 "github.com/stretchr/testify/require" 12 13 "github.com/iotexproject/iotex-core/test/identityset" 14 "github.com/iotexproject/iotex-core/testutil" 15 ) 16 17 func TestEpochMetaSerializeAndDeserialize(t *testing.T) { 18 require := require.New(t) 19 20 bm1 := NewBlockMeta(uint64(1), identityset.Address(1).String(), testutil.TimestampNow()) 21 ss, err := bm1.Serialize() 22 require.NoError(err) 23 bm2 := &BlockMeta{} 24 require.NoError(bm2.Deserialize(ss)) 25 require.Equal(bm1.Height, bm2.Height) 26 require.Equal(bm1.Producer, bm2.Producer) 27 require.Equal(bm1.MintTime, bm2.MintTime) 28 }