github.com/MetalBlockchain/metalgo@v1.11.9/vms/components/avax/test_verifiable.go (about)

     1  // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
     2  // See the file LICENSE for licensing terms.
     3  
     4  package avax
     5  
     6  import (
     7  	"github.com/MetalBlockchain/metalgo/snow"
     8  	"github.com/MetalBlockchain/metalgo/vms/components/verify"
     9  )
    10  
    11  var (
    12  	_ verify.State    = (*TestState)(nil)
    13  	_ TransferableOut = (*TestTransferable)(nil)
    14  	_ Addressable     = (*TestAddressable)(nil)
    15  )
    16  
    17  type TestState struct {
    18  	verify.IsState `json:"-"`
    19  
    20  	Err error
    21  }
    22  
    23  func (*TestState) InitCtx(*snow.Context) {}
    24  
    25  func (v *TestState) Verify() error {
    26  	return v.Err
    27  }
    28  
    29  type TestTransferable struct {
    30  	TestState
    31  
    32  	Val uint64 `serialize:"true"`
    33  }
    34  
    35  func (*TestTransferable) InitCtx(*snow.Context) {}
    36  
    37  func (t *TestTransferable) Amount() uint64 {
    38  	return t.Val
    39  }
    40  
    41  func (*TestTransferable) Cost() (uint64, error) {
    42  	return 0, nil
    43  }
    44  
    45  type TestAddressable struct {
    46  	TestTransferable `serialize:"true"`
    47  
    48  	Addrs [][]byte `serialize:"true"`
    49  }
    50  
    51  func (a *TestAddressable) Addresses() [][]byte {
    52  	return a.Addrs
    53  }