-
Notifications
You must be signed in to change notification settings - Fork 325
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
chore: test 4epochs in native-network #9309
Merged
Merged
Changes from 15 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
870260e
script fixes
ludamad 8ed7059
other scripts
ludamad 0a64362
Merge branch 'master' into ad/native-net-script-fixes
ludamad aa005e0
Update run_native_testnet.sh
ludamad f4d6e74
pass
ludamad 9cb16c0
test.sh fix
ludamad 8452bea
fix validator command
ludamad f6b25ae
fix validator command
ludamad 2b25c82
Update earthly-ci
ludamad c98c226
Merge branch 'master' into ad/native-net-script-fixes
ludamad 2738fc2
Update earthly-ci
ludamad 6e585da
flock on earthly restart
ludamad 6d4edee
Merge remote-tracking branch 'origin/ad/native-net-script-fixes' into…
ludamad 153e46a
port new tests
ludamad db3499b
fixes
ludamad 686195d
update
ludamad 48b6411
fix
ludamad e89cd7e
missing file
ludamad 90d1246
.
ludamad ac26c3e
yarn fix
ludamad 79b2b29
try fix
ludamad 4bde9cf
try fix
ludamad e4b1828
try fix
ludamad 6efa7d7
Merge branch 'master' into ad/4epochs
ludamad ce415ec
Merge branch 'master' into ad/4epochs
ludamad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,19 +27,18 @@ colors=( | |
"\e[91m" # Bright Red | ||
) | ||
|
||
FINISHED=false | ||
main_cmd="$1" | ||
shift | ||
|
||
# pattern from https://stackoverflow.com/questions/28238952/how-to-kill-a-running-bash-function-from-terminal | ||
function cleanup_function() { | ||
kill $(jobs -p) 2>/dev/null || true | ||
return | ||
function cleanup() { | ||
# kill everything in our process group except our process | ||
trap - SIGTERM && kill $(pgrep -g $$ | grep -v $$) 2>/dev/null || true | ||
} | ||
trap cleanup SIGINT SIGTERM EXIT | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More robust closing |
||
# Function to run a command and prefix the output with color | ||
function run_command() { | ||
# pattern from https://stackoverflow.com/questions/28238952/how-to-kill-a-running-bash-function-from-terminal | ||
trap cleanup_function INT EXIT | ||
local cmd="$1" | ||
local color="$2" | ||
$cmd 2>&1 | while IFS= read -r line; do | ||
|
@@ -50,9 +49,10 @@ function run_command() { | |
# Run background commands without logging output | ||
i=0 | ||
for cmd in "$@"; do | ||
run_command "$cmd" "${colors[$((i % ${#colors[@]}))]}" & | ||
(run_command "$cmd" "${colors[$((i % ${#colors[@]}))]}" || [ $FINISHED = true ] || (echo "$cmd causing terminate" && kill 0) ) & | ||
((i++)) || true # annoyingly considered a failure based on result | ||
done | ||
|
||
# Run the main command synchronously, piping output through the run_command function with green color | ||
run_command "$main_cmd" "\e[32m" | ||
run_command "$main_cmd" "\e[32m" || (echo "$main_cmd causing terminate" && kill 0) | ||
FINISHED=true |
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 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
34 changes: 0 additions & 34 deletions
34
yarn-project/end-to-end/scripts/native-network/test-transfer.sh
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
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,86 @@ | ||
import { EthCheatCodes, readFieldCompressedString } from '@aztec/aztec.js'; | ||
import { AZTEC_SLOT_DURATION } from '@aztec/circuits.js'; | ||
import { createDebugLogger } from '@aztec/foundation/log'; | ||
import { TokenContract } from '@aztec/noir-contracts.js'; | ||
|
||
import { jest } from '@jest/globals'; | ||
|
||
import { RollupCheatCodes } from '../../../aztec.js/src/utils/cheat_codes.js'; | ||
import { type TestWallets, setupTestWalletsWithTokens } from './setup_test_wallets.js'; | ||
|
||
const { PXE_URL, ETHEREUM_HOST } = process.env; | ||
if (!PXE_URL) { | ||
throw new Error('PXE_URL env variable must be set'); | ||
} | ||
if (!ETHEREUM_HOST) { | ||
throw new Error('ETHEREUM_HOST env variable must be set'); | ||
} | ||
|
||
describe('token transfer test', () => { | ||
jest.setTimeout(10 * 60 * 2000); // 20 minutes | ||
|
||
const logger = createDebugLogger(`aztec:spartan:4epochs`); | ||
// We want plenty of minted tokens for a lot of slots that fill up multiple epochs | ||
const MINT_AMOUNT = 2000000n; | ||
const TEST_EPOCHS = 4; | ||
const ROUNDS = BigInt(AZTEC_SLOT_DURATION * TEST_EPOCHS); | ||
|
||
let testWallets: TestWallets; | ||
|
||
beforeAll(async () => { | ||
testWallets = await setupTestWalletsWithTokens(PXE_URL, MINT_AMOUNT, logger); | ||
expect(ROUNDS).toBeLessThanOrEqual(MINT_AMOUNT); | ||
}); | ||
|
||
it('can get info', async () => { | ||
const name = readFieldCompressedString(await testWallets.tokenAdminWallet.methods.private_get_name().simulate()); | ||
expect(name).toBe(testWallets.tokenName); | ||
}); | ||
|
||
it('transfer tokens for 4 epochs', async () => { | ||
const ethCheatCodes = new EthCheatCodes(ETHEREUM_HOST); | ||
// Get 4 epochs | ||
const rollupCheatCodes = new RollupCheatCodes( | ||
ethCheatCodes, | ||
await testWallets.pxe.getNodeInfo().then(n => n.l1ContractAddresses), | ||
); | ||
const recipient = testWallets.recipientWallet.getAddress(); | ||
const transferAmount = 1n; | ||
|
||
testWallets.wallets.forEach(async w => { | ||
expect(MINT_AMOUNT).toBe(await testWallets.tokenAdminWallet.methods.balance_of_public(w.getAddress()).simulate()); | ||
}); | ||
|
||
expect(0n).toBe(await testWallets.tokenAdminWallet.methods.balance_of_public(recipient).simulate()); | ||
|
||
// For each round, make both private and public transfers | ||
const startSlot = await rollupCheatCodes.getSlot(); | ||
for (let i = 1n; i <= ROUNDS; i++) { | ||
const interactions = await Promise.all([ | ||
...testWallets.wallets.map(async w => | ||
( | ||
await TokenContract.at(testWallets.tokenAddress, w) | ||
).methods.transfer_public(w.getAddress(), recipient, transferAmount, 0), | ||
), | ||
]); | ||
|
||
const txs = await Promise.all(interactions.map(async i => await i.prove())); | ||
|
||
await Promise.all(txs.map(t => t.send().wait({ timeout: 600 }))); | ||
const currentSlot = await rollupCheatCodes.getSlot(); | ||
expect(currentSlot).toBe(startSlot + i); | ||
const startEpoch = await rollupCheatCodes.getEpoch(); | ||
logger.debug(`Successfully reached slot ${currentSlot} (iteration ${currentSlot - startSlot}/${ROUNDS}) (Epoch ${startEpoch})`); | ||
} | ||
|
||
testWallets.wallets.forEach(async w => { | ||
expect(MINT_AMOUNT - ROUNDS * transferAmount).toBe( | ||
await testWallets.tokenAdminWallet.methods.balance_of_public(w.getAddress()).simulate(), | ||
); | ||
}); | ||
|
||
expect(ROUNDS * transferAmount * BigInt(testWallets.wallets.length)).toBe( | ||
await testWallets.tokenAdminWallet.methods.balance_of_public(recipient).simulate(), | ||
); | ||
}); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bundled