github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/fvm/evm/types/tokenVault_test.go (about)

     1  package types_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/require"
     7  
     8  	"github.com/onflow/flow-go/fvm/evm/types"
     9  )
    10  
    11  func TestVault(t *testing.T) {
    12  
    13  	vault1 := types.NewFlowTokenVault(types.MakeABalanceInFlow(3))
    14  
    15  	vault2, err := vault1.Withdraw(types.OneFlowBalance)
    16  	require.NoError(t, err)
    17  
    18  	require.Equal(t, types.MakeABalanceInFlow(2), vault1.Balance())
    19  	require.Equal(t, types.OneFlowBalance, vault2.Balance())
    20  
    21  	toBeDeposited := types.NewFlowTokenVault(types.OneFlowBalance)
    22  	err = vault1.Deposit(toBeDeposited)
    23  	require.NoError(t, err)
    24  	require.Equal(t, types.MakeABalanceInFlow(3), vault1.Balance())
    25  	require.Equal(t, types.EmptyBalance, toBeDeposited.Balance())
    26  }