-
Notifications
You must be signed in to change notification settings - Fork 307
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
83 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 0 additions & 131 deletions
131
yarn-project/end-to-end/src/e2e_token_contract/shielding.test.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
yarn-project/end-to-end/src/e2e_token_contract/transfer_to_private.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { U128_UNDERFLOW_ERROR } from '../fixtures/fixtures.js'; | ||
import { TokenContractTest } from './token_contract_test.js'; | ||
|
||
describe('e2e_token_contract transfer_to_private', () => { | ||
const t = new TokenContractTest('transfer_to_private'); | ||
let { asset, accounts, tokenSim } = t; | ||
|
||
beforeAll(async () => { | ||
await t.applyBaseSnapshots(); | ||
await t.applyMintSnapshot(); | ||
await t.setup(); | ||
// Have to destructure again to ensure we have latest refs. | ||
({ asset, accounts, tokenSim } = t); | ||
}); | ||
|
||
afterAll(async () => { | ||
await t.teardown(); | ||
}); | ||
|
||
afterEach(async () => { | ||
await t.tokenSim.check(); | ||
}); | ||
|
||
it('to self', async () => { | ||
const balancePub = await asset.methods.balance_of_public(accounts[0].address).simulate(); | ||
const amount = balancePub / 2n; | ||
expect(amount).toBeGreaterThan(0n); | ||
|
||
await asset.methods.transfer_to_private(accounts[0].address, amount).send().wait(); | ||
|
||
// Check that the result matches token sim | ||
tokenSim.transferToPrivate(accounts[0].address, accounts[0].address, amount); | ||
await tokenSim.check(); | ||
}); | ||
|
||
it('to someone else', async () => { | ||
const balancePub = await asset.methods.balance_of_public(accounts[0].address).simulate(); | ||
const amount = balancePub / 2n; | ||
expect(amount).toBeGreaterThan(0n); | ||
|
||
await asset.methods.transfer_to_private(accounts[1].address, amount).send().wait(); | ||
|
||
// Check that the result matches token sim | ||
tokenSim.transferToPrivate(accounts[0].address, accounts[1].address, amount); | ||
await tokenSim.check(); | ||
}); | ||
|
||
describe('failure cases', () => { | ||
it('to self (more than balance)', async () => { | ||
const balancePub = await asset.methods.balance_of_public(accounts[0].address).simulate(); | ||
const amount = balancePub + 1n; | ||
expect(amount).toBeGreaterThan(0n); | ||
|
||
await expect(asset.methods.transfer_to_private(accounts[0].address, amount).simulate()).rejects.toThrow( | ||
U128_UNDERFLOW_ERROR, | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters