-
Notifications
You must be signed in to change notification settings - Fork 270
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
6 changed files
with
77 additions
and
5 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
62 changes: 62 additions & 0 deletions
62
yarn-project/end-to-end/src/e2e_native_fee_payments.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,62 @@ | ||
import { AztecAddress, ContractDeployer, NativeFeePaymentMethod } from '@aztec/aztec.js'; | ||
import { GasTokenContract, TokenContract } from '@aztec/noir-contracts'; | ||
import { getCanonicalGasToken } from '@aztec/protocol-contracts/gas-token'; | ||
|
||
import { setup } from './fixtures/utils.js'; | ||
|
||
describe('e2e_native_fee_payments', () => { | ||
let aliceAddress: AztecAddress; | ||
let _bobAddress: AztecAddress; | ||
let sequencerAddress: AztecAddress; | ||
let gasTokenContract: GasTokenContract; | ||
let testContract: TokenContract; | ||
|
||
beforeAll(async () => { | ||
const { accounts, sequencer, wallet } = await setup(3); | ||
sequencer?.updateSequencerConfig({ | ||
feeRecipient: accounts.at(-1)!.address, | ||
}); | ||
const canonicalGasToken = getCanonicalGasToken(); | ||
const deployer = new ContractDeployer(canonicalGasToken.artifact, wallet); | ||
const { contract } = await deployer | ||
.deploy() | ||
.send({ | ||
contractAddressSalt: canonicalGasToken.instance.salt, | ||
}) | ||
.wait(); | ||
|
||
gasTokenContract = contract as GasTokenContract; | ||
aliceAddress = accounts.at(0)!.address; | ||
_bobAddress = accounts.at(1)!.address; | ||
sequencerAddress = sequencer!.feeRecipient; | ||
|
||
testContract = await TokenContract.deploy(wallet, aliceAddress, 'Test', 'TEST', 1).send().deployed(); | ||
|
||
// Alice gets a balance of 1000 gas token | ||
await gasTokenContract.methods.redeem_bridged_balance(1000).send().wait(); | ||
}, 100_000); | ||
|
||
it('deploys gas token contract at canonical address', () => { | ||
expect(gasTokenContract.address).toEqual(getCanonicalGasToken().address); | ||
}); | ||
|
||
it('pays out the expected fee to the sequencer', async () => { | ||
await testContract.methods | ||
.mint_public(aliceAddress, 1000) | ||
.send({ | ||
fee: { | ||
maxFee: 1, | ||
paymentMethod: new NativeFeePaymentMethod(), | ||
}, | ||
}) | ||
.wait(); | ||
|
||
const [sequencerBalance, aliceBalance] = await Promise.all([ | ||
gasTokenContract.methods.balance_of(sequencerAddress).view(), | ||
gasTokenContract.methods.balance_of(aliceAddress).view(), | ||
]); | ||
|
||
expect(sequencerBalance).toEqual(1n); | ||
expect(aliceBalance).toEqual(999n); | ||
}); | ||
}); |
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