github.com/iotexproject/iotex-core@v1.14.1-rc1/blockchain/block/builder_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 block
     7  
     8  import (
     9  	"testing"
    10  
    11  	"github.com/stretchr/testify/require"
    12  
    13  	"github.com/iotexproject/go-pkgs/hash"
    14  	"github.com/iotexproject/iotex-core/test/identityset"
    15  	"github.com/iotexproject/iotex-core/testutil"
    16  )
    17  
    18  func TestBuilder(t *testing.T) {
    19  	ra := NewRunnableActionsBuilder().Build()
    20  
    21  	nblk, err := NewBuilder(ra).
    22  		SetHeight(1).
    23  		SetTimestamp(testutil.TimestampNow()).
    24  		SetPrevBlockHash(hash.ZeroHash256).
    25  		SignAndBuild(identityset.PrivateKey(29))
    26  	require.NoError(t, err)
    27  
    28  	require.True(t, nblk.VerifySignature())
    29  }