github.com/MetalBlockchain/metalgo@v1.11.9/vms/nftfx/transfer_output_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 nftfx
     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/verify"
    13  	"github.com/MetalBlockchain/metalgo/vms/secp256k1fx"
    14  )
    15  
    16  func TestTransferOutputVerifyNil(t *testing.T) {
    17  	to := (*TransferOutput)(nil)
    18  	err := to.Verify()
    19  	require.ErrorIs(t, err, errNilTransferOutput)
    20  }
    21  
    22  func TestTransferOutputLargePayload(t *testing.T) {
    23  	to := TransferOutput{
    24  		Payload: make([]byte, MaxPayloadSize+1),
    25  	}
    26  	err := to.Verify()
    27  	require.ErrorIs(t, err, errPayloadTooLarge)
    28  }
    29  
    30  func TestTransferOutputInvalidSecp256k1Output(t *testing.T) {
    31  	to := TransferOutput{
    32  		OutputOwners: secp256k1fx.OutputOwners{
    33  			Addrs: []ids.ShortID{
    34  				ids.ShortEmpty,
    35  				ids.ShortEmpty,
    36  			},
    37  		},
    38  	}
    39  	err := to.Verify()
    40  	require.ErrorIs(t, err, secp256k1fx.ErrOutputUnoptimized)
    41  }
    42  
    43  func TestTransferOutputState(t *testing.T) {
    44  	intf := interface{}(&TransferOutput{})
    45  	_, ok := intf.(verify.State)
    46  	require.True(t, ok)
    47  }