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

[Tests] Added script functions to argument types test suite #157

Merged
merged 8 commits into from
Nov 6, 2023

Conversation

xbtmatt
Copy link
Contributor

@xbtmatt xbtmatt commented Nov 1, 2023

Description

Updated the test suite to use scripts

The sender/authenticator type is already validated in transaction submission, so in order to keep this test focused, I just added scripts instead of adding all the different signer types.

Test suite

TODO:

  • Add 1 - n signers for the functions
  • Verify the order of signers in the contract with assertions

Argument types

  • basic argument types
  • vector argument types
  • option argument types
  • deeply nested complex types

Number of signers

  • One signer
  • Multiple signers

TODO:

  • view function of all the argument types listed above
  • type tags, including various nested generics

NOTE: Also added a small fix to the script function vector U8 serialize function. This is only needed for U8 because script functions don't accept any other vector type.

Test Plan

pnpm jest transactionArguments.test.ts --verbose

tests/move/arguments/sources/multi_signer.move Outdated Show resolved Hide resolved
tests/move/arguments/sources/main.move Outdated Show resolved Hide resolved
tests/move/arguments/sources/main.move Outdated Show resolved Hide resolved
src/bcs/serializable/moveStructs.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@0xmaayan 0xmaayan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall lgtm, makes me think we need to improve our testing framework and consolidate all helpers/testing objects/etc.

@xbtmatt xbtmatt force-pushed the matt/args-test branch 2 times, most recently from 78b29d4 to cbe6643 Compare November 4, 2023 00:15
const transaction = await aptos.generateTransaction({
sender: firstAccount.accountAddress.toString(),
data: {
function: `0x${1}::aptos_account::batch_transfer`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol why like this? If this is doing a pattern match that makes you do something like this, we need to fix it and remove the pattern match

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol I have no idea why I did this- it's fine with just the string, I updated it

function: `0x${1}::aptos_account::batch_transfer`,
functionArguments: [
new MoveVector(addressesRemaining),
MoveVector.U64(addressesRemaining.map(() => amountToSend)),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why map if it's exactly one?

await aptos.fundAccount({ accountAddress: firstAccount.accountAddress.toString(), amount: FUND_AMOUNT });
// Fund again because these txns can be expensive
await aptos.fundAccount({ accountAddress: firstAccount.accountAddress.toString(), amount: FUND_AMOUNT });
const addressesRemaining = accounts.slice(1).map((account) => account.accountAddress);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just accounts[1]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll put a comment explaining it so it's easier to read, but it's sending the coins from account[0] out to accounts[1..n] not just accounts[1]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if end in Array.slice(start?: number, end?: number) is undefined then it returns the slice from start to the end

@xbtmatt xbtmatt enabled auto-merge (squash) November 6, 2023 22:21
@xbtmatt xbtmatt merged commit 9adba32 into main Nov 6, 2023
10 checks passed
@xbtmatt xbtmatt deleted the matt/args-test branch November 6, 2023 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants