Skip to content

Commit

Permalink
Merge pull request #492 from bancorprotocol/fix-health-tests
Browse files Browse the repository at this point in the history
fix health tests
  • Loading branch information
ivanzhelyazkov authored Aug 28, 2024
2 parents 4d3070b + 3db58bb commit a4188c8
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 13 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
test:
name: Test

runs-on: [self-hosted, CI]
runs-on: ubuntu-latest
timeout-minutes: 600

steps:
Expand Down Expand Up @@ -54,5 +54,13 @@ jobs:
- name: Build
run: yarn build

- name: Setup tenderly
run: |
mkdir ~/.tenderly
touch ~/.tenderly/config.yaml
echo "access_key: $TENDERLY_ACCESS_KEY" >> ~/.tenderly/config.yaml
env:
TENDERLY_ACCESS_KEY: ${{ secrets.TENDERLY_ACCESS_KEY }}

- name: Test
run: yarn test:ci
12 changes: 9 additions & 3 deletions .github/workflows/health.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ jobs:
test:
name: Health Checks

runs-on: [self-hosted, HEALTH]
timeout-minutes: 600
runs-on: ubuntu-latest

steps:
- name: Check out the repository
Expand Down Expand Up @@ -43,11 +42,18 @@ jobs:
- name: Build
run: yarn build

- name: Setup tenderly
run: |
mkdir ~/.tenderly
touch ~/.tenderly/config.yaml
echo "access_key: $TENDERLY_ACCESS_KEY" >> ~/.tenderly/config.yaml
env:
TENDERLY_ACCESS_KEY: ${{ secrets.TENDERLY_ACCESS_KEY }}

- name: Test deployment and network health
run: yarn test:health
env:
TENDERLY_PROJECT: v3-temp-forks
TENDERLY_TEST_PROJECT: v3-temp-forks
TENDERLY_USERNAME: bancor
TENDERLY_ACCESS_KEY: ${{ secrets.TENDERLY_ACCESS_KEY }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
2 changes: 0 additions & 2 deletions deploy/tests/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ import { getNamedAccounts } from 'hardhat';
});

it('should have the correct set of roles', async () => {
const { deployer, deployerV2 } = await getNamedAccounts();

// ensure that ownership transfer to the DAO was initiated
expect(await liquidityProtection.newOwner()).to.equal(daoMultisig.address);

Expand Down
32 changes: 29 additions & 3 deletions deployments/run-fork.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ else
project=${TENDERLY_PROJECT}
fi

# Read the network name from the environment variable, default to 'mainnet' if not set
network_name=${TENDERLY_NETWORK_NAME:-'mainnet'}

# Check if network_id is null or empty
if [ -z "$network_id" ] || [ "$network_id" == "null" ]; then
# Fallback to the default network ID
network_id=${TENDERLY_NETWORK_ID:-"1"}
fi

echo "Creating a $network_name Tenderly Fork with Chain Id $network_id... "
echo

TENDERLY_FORK_API="https://api.tenderly.co/api/v1/account/${username}/project/${project}/fork"

cleanup() {
Expand All @@ -28,12 +40,26 @@ trap cleanup TERM EXIT

fork_id=$(curl -sX POST "${TENDERLY_FORK_API}" \
-H "Content-Type: application/json" -H "X-Access-Key: ${TENDERLY_ACCESS_KEY}" \
-d '{"network_id": "1"}' | jq -r '.simulation_fork.id')
-d '{"network_id": "'${network_id}'"}' | jq -r '.simulation_fork.id')

echo "Created a fork ${fork_id} at ${username}/${project}..."
echo "Created Tenderly Fork ${fork_id} at ${username}/${project}..."
echo

command="TENDERLY_FORK_ID=${fork_id} ${@:1}"
# if deployments/${network_name} doesn't exist, create it and create a .chainId file
if [ ! -d "./deployments/${network_name}" ]; then
mkdir -p ./deployments/${network_name}
echo ${network_id} > ./deployments/${network_name}/.chainId
fi

# if deploy/scripts/${network_name} doesn't exist, create it and copy the network scripts
if [ ! -d "./deploy/scripts/${network_name}" ]; then
rsync -a --delete ./deploy/scripts/network/ ./deploy/scripts/${network_name}/
fi

# Create a new dir for the deploy script files and copy them there
rm -rf deployments/tenderly && cp -rf deployments/${network_name}/. deployments/tenderly

command="TENDERLY_FORK_ID=${fork_id} TENDERLY_NETWORK_NAME=${network_name} ${@:1}"

echo "Running:"
echo
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"test:coverage:nightly": "NIGHTLY=1 yarn test:coverage",
"test:ci": "CI=1 yarn test",
"test:nightly": "NIGHTLY=1 CI=1 NODE_OPTIONS='--max-old-space-size=8192' hardhat test",
"test:deploy": "yarn deploy:prepare:fork && TEST_FORK=1 ./deployments/run-fork.sh HARDHAT_NETWORK=tenderly mocha --require hardhat/register --extension ts --recursive --exit --timeout 600000 --bail --no-exit 'deploy/tests/**/*.ts'",
"test:health": "yarn test:deploy --reporter test/reporters/SentryReporter",
"test:deploy": "TEST_FORK=1 ./deployments/run-fork.sh HARDHAT_NETWORK=tenderly mocha --require hardhat/register --extension ts --recursive --exit --timeout 600000 --bail --no-exit 'deploy/tests/**/*.ts'",
"test:health": "yarn test:deploy",
"export:storage": "yarn rebuild && hardhat run deployments/storage-layout.ts",
"deploy:prepare": "rm -rf ./node_modules && rm yarn.lock && yarn && yarn rebuild",
"deploy:prepare:fork": "rm -rf deployments/tenderly && cp -rf deployments/mainnet/. deployments/tenderly",
Expand Down
3 changes: 1 addition & 2 deletions test/network/BancorNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3190,13 +3190,12 @@ describe('BancorNetwork', () => {
let token: TokenWithAddress;

let emergencyStopper: SignerWithAddress;
let networkFeeManager: SignerWithAddress;

const INITIAL_LIQUIDITY = toWei(50_000_000);
const TRADING_FEE_PPM = toPPM(10);

before(async () => {
[, emergencyStopper, networkFeeManager] = await ethers.getSigners();
[, emergencyStopper] = await ethers.getSigners();
});

beforeEach(async () => {
Expand Down

0 comments on commit a4188c8

Please sign in to comment.