Skip to content

Commit

Permalink
test: TestContractCallTx_FeeEstimate makes sure that the fee estimate…
Browse files Browse the repository at this point in the history
… is working properly
  • Loading branch information
randomshinichi committed May 27, 2019
1 parent 934ef00 commit d750d14
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions aeternity/transactions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,71 @@ func TestContractCallTx_RLP(t *testing.T) {
}
}

func TestContractCallTx_FeeEstimate(t *testing.T) {
type fields struct {
CallerID string
AccountNonce uint64
ContractID string
Amount utils.BigInt
Gas utils.BigInt
GasPrice utils.BigInt
AbiVersion uint64
VMVersion uint64
CallData string
Fee utils.BigInt
TTL uint64
}
tests := []struct {
name string
fields fields
want *utils.BigInt
wantErr bool
}{
{
name: "Fortuna (AbiVersion 4), with fixed params for fee estimation",
fields: fields{
CallerID: "ak_2a1j2Mk9YSmC1gioUq4PWRm3bsv887MbuRVwyv4KaUGoR1eiKi",
AccountNonce: uint64(2),
ContractID: "ct_2pfWWzeRzWSdm68HXZJn61KhxdsBA46wzYgvo1swkdJZij1rKm",
Amount: *utils.NewBigIntFromUint64(0),
Gas: *utils.NewBigIntFromUint64(1e5),
GasPrice: *utils.NewBigIntFromUint64(1e9),
AbiVersion: uint64(4),
VMVersion: uint64(1),
CallData: "cb_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACDiIx1s38k5Ft5Ms6mFe/Zc9A/CVvShSYs/fnyYDBmTRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACo7j+li",
Fee: *utils.NewBigIntFromUint64(2e9),
TTL: 0,
},
want: utils.NewBigIntFromUint64(554440000000000),
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tx := &ContractCallTx{
CallerID: tt.fields.CallerID,
AccountNonce: tt.fields.AccountNonce,
ContractID: tt.fields.ContractID,
Amount: tt.fields.Amount,
Gas: tt.fields.Gas,
GasPrice: tt.fields.GasPrice,
AbiVersion: tt.fields.AbiVersion,
VMVersion: tt.fields.VMVersion,
CallData: tt.fields.CallData,
Fee: tt.fields.Fee,
TTL: tt.fields.TTL,
}
got, err := tx.FeeEstimate()
if (err != nil) != tt.wantErr {
t.Errorf("ContractCallTx.FeeEstimate() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("ContractCallTx.FeeEstimate() = %v, want %v", got, tt.want)
}
})
}
}
func Test_encodeVMABI(t *testing.T) {
type args struct {
VMVersion uint64
Expand Down

0 comments on commit d750d14

Please sign in to comment.