|
1 | 1 | import { getInitialTestAccountsData } from '@aztec/accounts/testing'; |
2 | | -import type { PXE } from '@aztec/aztec.js'; |
| 2 | +import { Fr, type PXE } from '@aztec/aztec.js'; |
3 | 3 | import { AmmBot, Bot, type BotConfig, SupportedTokenContracts, getBotDefaultConfig } from '@aztec/bot'; |
4 | 4 | import { AVM_MAX_PROCESSABLE_L2_GAS, MAX_PROCESSABLE_DA_GAS_PER_BLOCK } from '@aztec/constants'; |
| 5 | +import { SecretValue } from '@aztec/foundation/config'; |
| 6 | +import { bufferToHex } from '@aztec/foundation/string'; |
5 | 7 |
|
6 | | -import { setup } from './fixtures/utils.js'; |
| 8 | +import { type EndToEndContext, getPrivateKeyFromIndex, setup } from './fixtures/utils.js'; |
7 | 9 |
|
8 | 10 | describe('e2e_bot', () => { |
9 | 11 | let pxe: PXE; |
10 | 12 | let teardown: () => Promise<void>; |
11 | 13 |
|
12 | 14 | let config: BotConfig; |
| 15 | + let ctx: EndToEndContext; |
13 | 16 |
|
14 | 17 | beforeAll(async () => { |
15 | 18 | const initialFundedAccounts = await getInitialTestAccountsData(); |
16 | | - ({ teardown, pxe } = await setup(1, { |
17 | | - initialFundedAccounts, |
18 | | - })); |
| 19 | + ctx = await setup(1, { initialFundedAccounts }); |
| 20 | + ({ teardown, pxe } = ctx); |
19 | 21 | }); |
20 | 22 |
|
21 | 23 | afterAll(() => teardown()); |
@@ -59,13 +61,7 @@ describe('e2e_bot', () => { |
59 | 61 | }); |
60 | 62 |
|
61 | 63 | it('sends token from the bot using PrivateToken', async () => { |
62 | | - const easyBot = await Bot.create( |
63 | | - { |
64 | | - ...config, |
65 | | - contract: SupportedTokenContracts.PrivateTokenContract, |
66 | | - }, |
67 | | - { pxe }, |
68 | | - ); |
| 64 | + const easyBot = await Bot.create({ ...config, contract: SupportedTokenContracts.PrivateTokenContract }, { pxe }); |
69 | 65 | const { recipient: recipientBefore } = await easyBot.getBalances(); |
70 | 66 |
|
71 | 67 | await easyBot.run(); |
@@ -105,4 +101,25 @@ describe('e2e_bot', () => { |
105 | 101 | ).toBeTrue(); |
106 | 102 | }); |
107 | 103 | }); |
| 104 | + |
| 105 | + describe('setup via bridging funds cross-chain', () => { |
| 106 | + beforeAll(() => { |
| 107 | + config = { |
| 108 | + ...getBotDefaultConfig(), |
| 109 | + followChain: 'PENDING', |
| 110 | + ammTxs: false, |
| 111 | + senderPrivateKey: new SecretValue(Fr.random()), |
| 112 | + l1PrivateKey: new SecretValue(bufferToHex(getPrivateKeyFromIndex(8)!)), |
| 113 | + l1RpcUrls: ctx.config.l1RpcUrls, |
| 114 | + flushSetupTransactions: true, |
| 115 | + }; |
| 116 | + }); |
| 117 | + |
| 118 | + // See 'can consume L1 to L2 message in %s after inbox drifts away from the rollup' |
| 119 | + // in end-to-end/src/e2e_cross_chain_messaging/l1_to_l2.test.ts for context on this test. |
| 120 | + it('creates bot after inbox drift', async () => { |
| 121 | + await ctx.cheatCodes.rollup.advanceInboxInProgress(10); |
| 122 | + await Bot.create(config, { pxe, node: ctx.aztecNode, nodeAdmin: ctx.aztecNodeAdmin }); |
| 123 | + }, 300_000); |
| 124 | + }); |
108 | 125 | }); |
0 commit comments