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: add transfer to undeployed account #7015

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Fr, computeAuthWitMessageHash } from '@aztec/aztec.js';
import { AztecAddress, CompleteAddress, Fr, computeAuthWitMessageHash } from '@aztec/aztec.js';

import { DUPLICATE_NULLIFIER_ERROR } from '../fixtures/fixtures.js';
import { TokenContractTest } from './token_contract_test.js';
Expand Down Expand Up @@ -30,6 +30,22 @@ describe('e2e_token_contract transfer private', () => {
tokenSim.transferPrivate(accounts[0].address, accounts[1].address, amount);
});

it('transfer less than balance to non-deployed account', async () => {
const balance0 = await asset.methods.balance_of_private(accounts[0].address).simulate();
const amount = balance0 / 2n;
expect(amount).toBeGreaterThan(0n);

const nonDeployed = CompleteAddress.random();
await wallets[0].registerRecipient(nonDeployed);

await asset.methods.transfer(nonDeployed.address, amount).send().wait();

// Add the account as balance we should change, but since we don't have the key,
// we cannot decrypt, and instead we simulate a transfer to address(0)
tokenSim.addAccount(nonDeployed.address);
tokenSim.transferPrivate(accounts[0].address, AztecAddress.ZERO, amount);
});

it('transfer to self', async () => {
const balance0 = await asset.methods.balance_of_private(accounts[0].address).simulate();
const amount = balance0 / 2n;
Expand Down
Loading