Skip to content

Commit

Permalink
feat: Contract Call Tx works
Browse files Browse the repository at this point in the history
  • Loading branch information
randomshinichi committed May 27, 2019
1 parent 1bf0497 commit ac88116
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
2 changes: 2 additions & 0 deletions aeternity/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,7 @@ func NewContractCreateTx(OwnerID string, AccountNonce uint64, Code string, VMVer
}

// ContractCallTx represents calling an existing smart contract
// VMVersion is not included in RLP serialized representation (implied by contract type already)
type ContractCallTx struct {
CallerID string
AccountNonce uint64
Expand Down Expand Up @@ -1065,6 +1066,7 @@ func (tx *ContractCallTx) RLP() (rlpRawMsg []byte, err error) {
cID,
tx.AccountNonce,
ctID,
tx.AbiVersion,
tx.Fee.Int,
tx.TTL,
tx.Amount.Int,
Expand Down
26 changes: 22 additions & 4 deletions aeternity/transactions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -916,21 +916,39 @@ func TestContractCallTx_RLP(t *testing.T) {
wantErr bool
}{
{
name: "Basic contract call tx",
name: "Minerva (AbiVersion 3)",
fields: fields{
CallerID: "ak_2a1j2Mk9YSmC1gioUq4PWRm3bsv887MbuRVwyv4KaUGoR1eiKi",
AccountNonce: uint64(1),
ContractID: "ct_2pfWWzeRzWSdm68HXZJn61KhxdsBA46wzYgvo1swkdJZij1rKm",
Amount: *utils.NewBigIntFromUint64(10),
Gas: *utils.NewBigIntFromUint64(10),
GasPrice: *utils.NewBigIntFromUint64(10),
AbiVersion: uint64(0),
VMVersion: uint64(0),
AbiVersion: uint64(3),
VMVersion: uint64(1),
CallData: "cb_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACDiIx1s38k5Ft5Ms6mFe/Zc9A/CVvShSYs/fnyYDBmTRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACo7j+li",
Fee: Config.Client.Fee,
TTL: Config.Client.TTL,
},
wantTx: "you tell me",
wantTx: "tx_+NcrAaEBzqet5HDJ+Z2dTkAIgKhvHUm7REti8Rqeu2S7z+tz/vMBoQXv7ERRuvBfaps6b3yVUqmUUEmGvanaJbGAxkh6t034wwOGteYg9IAAggH0CgoKuIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIOIjHWzfyTkW3kyzqYV79lz0D8JW9KFJiz9+fJgMGZNEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKk9Ku98=",
wantErr: false,
},
{
name: "Fortuna (AbiVersion 4), with Config defaults for gas etc",
fields: fields{
CallerID: "ak_2a1j2Mk9YSmC1gioUq4PWRm3bsv887MbuRVwyv4KaUGoR1eiKi",
AccountNonce: uint64(2),
ContractID: "ct_2pfWWzeRzWSdm68HXZJn61KhxdsBA46wzYgvo1swkdJZij1rKm",
Amount: Config.Client.Contracts.Amount,
Gas: Config.Client.Contracts.Gas,
GasPrice: Config.Client.Contracts.GasPrice,
AbiVersion: uint64(4),
VMVersion: uint64(1),
CallData: "cb_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACDiIx1s38k5Ft5Ms6mFe/Zc9A/CVvShSYs/fnyYDBmTRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACo7j+li",
Fee: Config.Client.Fee,
TTL: Config.Client.TTL,
},
wantTx: "tx_+N8rAaEBzqet5HDJ+Z2dTkAIgKhvHUm7REti8Rqeu2S7z+tz/vMCoQXv7ERRuvBfaps6b3yVUqmUUEmGvanaJbGAxkh6t034wwSGteYg9IAAggH0AIQ7msoAhDuaygC4gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAg4iMdbN/JORbeTLOphXv2XPQPwlb0oUmLP358mAwZk0QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAqty+KkQ==",
wantErr: false,
},
}
Expand Down

0 comments on commit ac88116

Please sign in to comment.