github.com/MetalBlockchain/metalgo@v1.11.9/vms/platformvm/block/atomic_block_test.go (about) 1 // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 package block 5 6 import ( 7 "testing" 8 9 "github.com/stretchr/testify/require" 10 11 "github.com/MetalBlockchain/metalgo/ids" 12 "github.com/MetalBlockchain/metalgo/vms/components/avax" 13 "github.com/MetalBlockchain/metalgo/vms/components/verify" 14 "github.com/MetalBlockchain/metalgo/vms/platformvm/txs" 15 ) 16 17 func TestNewApricotAtomicBlock(t *testing.T) { 18 require := require.New(t) 19 20 parentID := ids.GenerateTestID() 21 height := uint64(1337) 22 tx := &txs.Tx{ 23 Unsigned: &txs.ImportTx{ 24 BaseTx: txs.BaseTx{ 25 BaseTx: avax.BaseTx{ 26 Ins: []*avax.TransferableInput{}, 27 Outs: []*avax.TransferableOutput{}, 28 }, 29 }, 30 ImportedInputs: []*avax.TransferableInput{}, 31 }, 32 Creds: []verify.Verifiable{}, 33 } 34 require.NoError(tx.Initialize(txs.Codec)) 35 36 blk, err := NewApricotAtomicBlock( 37 parentID, 38 height, 39 tx, 40 ) 41 require.NoError(err) 42 43 // Make sure the block and tx are initialized 44 require.NotEmpty(blk.Bytes()) 45 require.NotEmpty(blk.Tx.Bytes()) 46 require.NotEqual(ids.Empty, blk.Tx.ID()) 47 require.Equal(tx.Bytes(), blk.Tx.Bytes()) 48 require.Equal(parentID, blk.Parent()) 49 require.Equal(height, blk.Height()) 50 }