Skip to content

Commit

Permalink
Fee currency e2e test (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
karlb committed Oct 11, 2023
1 parent 5bc747f commit f6e145e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
5 changes: 3 additions & 2 deletions e2e_test/run_all_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
set -eo pipefail

SCRIPT_DIR=$(readlink -f "$(dirname "$0")")
TEST_GLOB=$1

## Start geth
cd "$SCRIPT_DIR/.." || exit 1
Expand All @@ -24,7 +25,7 @@ echo Geth ready, start tests
failures=0
tests=0
cd "$SCRIPT_DIR" || exit 1
for f in test_*
for f in test_*"$TEST_GLOB"*
do
echo -e "\nRun $f"
if "./$f"
Expand All @@ -45,7 +46,7 @@ echo
if [[ $failures -eq 0 ]]
then
tput setaf 2 || true
echo All tests succeeded!
echo All $tests tests succeeded!
else
tput setaf 1 || true
echo $failures/$tests failed.
Expand Down
6 changes: 6 additions & 0 deletions e2e_test/shared.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ ACC_ADDR=0x42cf1bbc38BaAA3c4898ce8790e21eD2738c6A4a
ACC_PRIVKEY=0x2771aff413cac48d9f8c114fabddd9195a2129f3c2c436caa07e27bb7f58ead5
REGISTRY_ADDR=0x000000000000000000000000000000000000ce10
TOKEN_ADDR=0x000000000000000000000000000000000000ce12
FEE_CURRENCY_WHITELIST_ADDR=0x000000000000000000000000000000000000ce14
SORTED_ORACLES_ADDR=0x000000000000000000000000000000000000ce15
FEE_CURRENCY=0x000000000000000000000000000000000000ce16

FIXIDITY_1=1000000000000000000000000
ZERO_ADDRESS=0x0000000000000000000000000000000000000000
21 changes: 21 additions & 0 deletions e2e_test/test_fee_currency.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
#shellcheck disable=SC2086
set -eo pipefail
set -x

source shared.sh

# Register fee currency whitelist and sorted oracles
cast send --private-key $ACC_PRIVKEY $REGISTRY_ADDR 'function setAddressFor(string calldata identifier, address addr) external' FeeCurrencyWhitelist $FEE_CURRENCY_WHITELIST_ADDR
cast send --private-key $ACC_PRIVKEY $REGISTRY_ADDR 'function setAddressFor(string calldata identifier, address addr) external' SortedOracles $SORTED_ORACLES_ADDR
# Add our account as oracle and submit value
cast send --private-key $ACC_PRIVKEY $SORTED_ORACLES_ADDR 'function addOracle(address token, address oracleAddress) external' $FEE_CURRENCY $ACC_ADDR
cast send --private-key $ACC_PRIVKEY $SORTED_ORACLES_ADDR 'function report(address token, uint256 value, address lesserKey, address greaterKey) external' $FEE_CURRENCY $FIXIDITY_1 $ZERO_ADDRESS $ZERO_ADDRESS

# Debug suggestions:
# cast call $FEE_CURRENCY_WHITELIST_ADDR 'function getWhitelist() external view returns (address[] memory)'
# cast logs 'event OracleReported(address indexed token, address indexed oracle, uint256 timestamp, uint256 value)'
# cast call $SORTED_ORACLES_ADDR 'function medianRate(address token) external view returns (uint256, uint256)' $FEE_CURRENCY

# Send token and check balance (TODO: add fee currency)
cast send --private-key $ACC_PRIVKEY --value 10 0x000000000000000000000000000000000000dEaD

0 comments on commit f6e145e

Please sign in to comment.