Skip to content

Commit

Permalink
Run e2e tests on alfajores (#258)
Browse files Browse the repository at this point in the history
Modifies our e2e tests to be able to run on alfajores if the
environment variable `NETWORK` is set to 'alfajores'.
Also adds a CI step to run them against alfajores.

Note that the `test_fee_currency...` tests are skipped
because they require the ability to deploy new fee currencies,
which we probably don't want to be doing on a live network
as it could cause issues for people, and we also don't want to
expose the credentials to do so.
  • Loading branch information
piersy authored Oct 21, 2024
1 parent c6d7b55 commit de410b1
Show file tree
Hide file tree
Showing 12 changed files with 358 additions and 117 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,14 @@ jobs:
with:
version: nightly-f625d0fa7c51e65b4bf1e8f7931cd1c6e2e285e9

- name: Run e2e tests
- name: Run e2e tests local
shell: bash
run: e2e_test/run_all_tests.sh

- name: Run e2e tests alfajores
shell: bash
run: NETWORK=alfajores e2e_test/run_all_tests.sh

Lint:
runs-on: ["8-cpu","self-hosted","org"]
steps:
Expand Down
4 changes: 2 additions & 2 deletions core/celo_genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ var (
DevAddr = common.BytesToAddress(DevAddr32.Bytes())
DevAddr32 = common.HexToHash("0x42cf1bbc38BaAA3c4898ce8790e21eD2738c6A4a")

DevFeeCurrencyAddr = common.HexToAddress("0xce16") // worth half as much as native CELO
DevFeeCurrencyAddr2 = common.HexToAddress("0xce17") // worth twice as much as native CELO
DevFeeCurrencyAddr = common.HexToAddress("0x000000000000000000000000000000000000ce16") // worth half as much as native CELO
DevFeeCurrencyAddr2 = common.HexToAddress("0x000000000000000000000000000000000000ce17") // worth twice as much as native CELO
DevBalance, _ = new(big.Int).SetString("100000000000000000000", 10)
rateNumerator, _ = new(big.Int).SetString("2000000000000000000000000", 10)
rateNumerator2, _ = new(big.Int).SetString("500000000000000000000000", 10)
Expand Down
4 changes: 2 additions & 2 deletions e2e_test/debug-fee-currency/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ function deploy_fee_currency() {
exit 1
fi
# this always resets the token address for the predeployed oracle3
cast send --private-key $ACC_PRIVKEY $ORACLE3 'setExchangeRate(address, uint256, uint256)' $fee_currency 2ether 1ether &>/dev/null
cast send --private-key $ACC_PRIVKEY $FEE_CURRENCY_DIRECTORY_ADDR 'setCurrencyConfig(address, address, uint256)' $fee_currency $ORACLE3 60000 &>/dev/null
cast send --private-key $ACC_PRIVKEY $ORACLE3 'setExchangeRate(address, uint256, uint256)' $fee_currency 2ether 1ether > /dev/null
cast send --private-key $ACC_PRIVKEY $FEE_CURRENCY_DIRECTORY_ADDR 'setCurrencyConfig(address, address, uint256)' $fee_currency $ORACLE3 60000 > /dev/null
echo "$fee_currency"
)
}
Expand Down
195 changes: 159 additions & 36 deletions e2e_test/js-tests/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion e2e_test/js-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"chai": "^5.0.0",
"ethers": "^6.10.0",
"mocha": "^10.2.0",
"viem": "^2.9.6"
"viem": "^2.21.18"
}
}
16 changes: 14 additions & 2 deletions e2e_test/js-tests/send_tx.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,29 @@ const devChain = defineChain({
},
});

var chain;
switch(process.env.NETWORK) {
case "alfajores":
chain = celoAlfajores;
break;
default:
chain = devChain;
// Code to run if no cases match
};

const account = privateKeyToAccount(privateKey);

const publicClient = createPublicClient({
account,
chain: devChain,
chain: chain,
transport: http(),
});
const walletClient = createWalletClient({
account,
chain: devChain,
chain: chain,
transport: http(),
});

function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
Expand Down Expand Up @@ -134,3 +145,4 @@ async function main() {
return receipt;
}
await main();
process.exit(0);
Loading

0 comments on commit de410b1

Please sign in to comment.