github.com/ava-labs/avalanchego@v1.11.11/vms/nftfx/mint_operation_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/ava-labs/avalanchego/vms/components/verify"
    12  	"github.com/ava-labs/avalanchego/vms/secp256k1fx"
    13  )
    14  
    15  func TestMintOperationVerifyNil(t *testing.T) {
    16  	op := (*MintOperation)(nil)
    17  	err := op.Verify()
    18  	require.ErrorIs(t, err, errNilMintOperation)
    19  }
    20  
    21  func TestMintOperationVerifyTooLargePayload(t *testing.T) {
    22  	op := MintOperation{
    23  		Payload: make([]byte, MaxPayloadSize+1),
    24  	}
    25  	err := op.Verify()
    26  	require.ErrorIs(t, err, errPayloadTooLarge)
    27  }
    28  
    29  func TestMintOperationVerifyInvalidOutput(t *testing.T) {
    30  	op := MintOperation{
    31  		Outputs: []*secp256k1fx.OutputOwners{{
    32  			Threshold: 1,
    33  		}},
    34  	}
    35  	err := op.Verify()
    36  	require.ErrorIs(t, err, secp256k1fx.ErrOutputUnspendable)
    37  }
    38  
    39  func TestMintOperationOuts(t *testing.T) {
    40  	op := MintOperation{
    41  		Outputs: []*secp256k1fx.OutputOwners{{}},
    42  	}
    43  	require.Len(t, op.Outs(), 1)
    44  }
    45  
    46  func TestMintOperationState(t *testing.T) {
    47  	intf := interface{}(&MintOperation{})
    48  	_, ok := intf.(verify.State)
    49  	require.False(t, ok)
    50  }