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

test: More tests for approve method of token program #979

Merged
merged 3 commits into from
Jul 10, 2024

Conversation

vadorovsky
Copy link
Contributor

Successful tests:

  • Delegating u64::MAX.

Failing tests:

  1. Invalid delegated compressed account Merkle tree.
  2. Invalid change compressed account Merkle tree.
  3. Invalid proof.
  4. Invalid mint.

Successful tests:

- Delegating `u64::MAX`.

Failing tests:

1. Invalid delegated compressed account Merkle tree.
2. Invalid change compressed account Merkle tree.
3. Invalid proof.
4. Invalid mint.
@@ -432,6 +435,226 @@ async fn test_delegation() {
kill_prover();
}

#[tokio::test]
#[ignore]
Copy link
Contributor

Choose a reason for hiding this comment

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

why ignore shouldn't this succeed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It actually doesn't suceed, trying to investigate why.

This assertion fails

        assert_eq!(
            transfer_recipient_token_compressed_account
                .token_data
                .delegate,
            delegates[i]
        );

To be precise, token_data.delegate is None. I'm trying to check if there is something in the instruction which prevents applying of the correct token_data when the amount is zero.

Copy link
Contributor Author

@vadorovsky vadorovsky Jul 10, 2024

Choose a reason for hiding this comment

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

nvm, fixed here cc5dcda

proof: proof_rpc_result.proof.clone(),
};
// NOTE(vadorovsky): Not sure what to do here!
// For now, this instruction returns `ProofVerificationFailed`, which
Copy link
Contributor

Choose a reason for hiding this comment

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

mint pubkey is part of the token data hash.
The token data hash is part of the compressed account hash which is a public input for proof verification.
-> makes sense that the proof fails
why does it feel wrong?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, we talked about it on 1on1. I was previously thinking that it'd be nice to have a dedicated error variant for that, but that'd be an overkill.

Removed the commend and added the assert.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, it's not ideal that we don't have a dedicated error. To throw a dedicated error we would need to send more data unfortunately. We do that in the system program because instruction data is less of a constraint in cpis.

Search for the output token with precise `delegate` in
`assert_compressed_token_accounts`. Otherwise, when multiple outputs
have the same amount, it always picks the first one, even if the
`delegate` doesn't match.
@vadorovsky vadorovsky marked this pull request as ready for review July 10, 2024 08:24
@ananas-block ananas-block merged commit fe5d0b6 into main Jul 10, 2024
17 checks passed
@ananas-block ananas-block deleted the vadorovsky/test-approve branch July 10, 2024 11:59
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.

2 participants