Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
vivekjain23 committed Jul 16, 2024
1 parent 7bd9338 commit ddb9e95
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions packages/evm/evmtest/wiki_how_tos/how_tos_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package wiki_how_tos_test

import (
"bytes"
_ "embed"
"math/big"
"strings"
Expand Down Expand Up @@ -127,19 +126,26 @@ func TestTakeAllowance(t *testing.T) {
instance := env.DeployContract(privateKey, TakeAllowanceContractABI, TakeAllowanceContractBytecode)

senderAgentID := isc.NewEthereumAddressAgentID(env.Chain.ChainID, deployer)
t.Log(senderAgentID)
// creating nft ID
NftIDBuffer := bytes.NewBufferString("0x0000000000000000000000000000000000000000000000000000000000000001")
nftID := [32]byte(NftIDBuffer.Bytes())

// mint an NFToken to the contract deployer
mockMetaData := []byte("sesa")
nfti, info, err := env.Chain.Env.MintNFTL1(env.Chain.OriginatorPrivateKey, env.Chain.OriginatorAddress, mockMetaData)
require.NoError(t, err)
env.Chain.MustDepositNFT(nfti, env.Chain.OriginatorAgentID, env.Chain.OriginatorPrivateKey)

transfer := isc.NewEmptyAssets()
transfer.AddNFTs(info.NFTID)

// send the NFT to the contract deployer
err = env.Chain.SendFromL2ToL2Account(transfer, senderAgentID, env.Chain.OriginatorPrivateKey)
require.NoError(t, err)

// allowing funds
result, err := instance.CallFn(nil, "allow", deployer, nftID)
instance.CallFn(nil, "allow", deployer, nfti.ID)
assert.Nil(t, err)

// t.Log("Allow :", result, err, info)

// taking allowed funds
result2, err := instance.CallFn(nil, "takeAllowedFunds", deployer, nftID)
assert.Nil(t, err)
t.Log("Take Allowed funds :", result, result2, err)
result, err := instance.CallFn(nil, "takeAllowedFunds", deployer, nfti.ID)
// assert.Nil(t, err)
t.Log("Take Allowed funds :", result, err)
}

0 comments on commit ddb9e95

Please sign in to comment.