Skip to content

Commit

Permalink
test: add transfer to undeployed account (#7015)
Browse files Browse the repository at this point in the history
Fixes #5637.
  • Loading branch information
LHerskind authored Jun 13, 2024
1 parent 9a0ced3 commit 46324b9
Showing 1 changed file with 17 additions and 1 deletion.
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

0 comments on commit 46324b9

Please sign in to comment.