Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBC transfer precompile #1459

Closed
wants to merge 16 commits into from
Prev Previous commit
Next Next commit
add gas assertions
  • Loading branch information
dssei committed Mar 22, 2024
commit cf9d1cad8e6188ba7d03f1082e164516279d341b
27 changes: 16 additions & 11 deletions precompiles/ibc/ibc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,20 @@ func TestPrecompile_Run(t *testing.T) {
}

tests := []struct {
name string
fields fields
args args
wantBz []byte
wantErr bool
name string
fields fields
args args
wantBz []byte
wantRemainingGas uint64
wantErr bool
}{
{
name: "successful transfer: with amount > 0 between EVM addresses",
fields: fields{transferKeeper: &MockTransferKeeper{}},
args: commonArgs,
wantBz: packedTrue,
wantErr: false,
name: "successful transfer: with amount > 0 between EVM addresses",
fields: fields{transferKeeper: &MockTransferKeeper{}},
args: commonArgs,
wantBz: packedTrue,
wantRemainingGas: 991911,
wantErr: false,
},
{
name: "failed transfer: internal error",
Expand Down Expand Up @@ -118,14 +120,17 @@ func TestPrecompile_Run(t *testing.T) {
tt.args.input.sourcePort, tt.args.input.sourceChannel, tt.args.input.denom, tt.args.input.amount,
tt.args.input.revisionNumber, tt.args.input.revisionHeight, tt.args.input.timeoutTimestamp)
require.Nil(t, err)
gotBz, _, err := p.RunAndCalculateGas(&evm, tt.args.caller, tt.args.callingContract, append(p.TransferID, inputs...), tt.args.suppliedGas, tt.args.value)
gotBz, g, err := p.RunAndCalculateGas(&evm, tt.args.caller, tt.args.callingContract, append(p.TransferID, inputs...), tt.args.suppliedGas, tt.args.value)
if (err != nil) != tt.wantErr {
t.Errorf("Run() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(gotBz, tt.wantBz) {
t.Errorf("Run() gotBz = %v, want %v", gotBz, tt.wantBz)
}
if !reflect.DeepEqual(g, tt.wantRemainingGas) {
t.Errorf("Run() gotRemainingGas = %v, want %v", g, tt.wantRemainingGas)
}
})
}
}