Skip to content

Commit

Permalink
Dapp and foundry tests CI (#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
hujw77 authored Nov 22, 2022
1 parent c762f83 commit b06a437
Show file tree
Hide file tree
Showing 15 changed files with 799 additions and 614 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/dapp-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "Dapp Build"
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: contracts/bridge
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v18
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v11
with:
name: dapp

- name: test
run: nix-shell --run 'make test'
26 changes: 26 additions & 0 deletions .github/workflows/foundry-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "Foundry Build"
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
FOUNDRY_PROFILE: ci

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: contracts/bridge
steps:
- uses: actions/checkout@v3
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: test
run: forge test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: "Hardhat Build"

on:
push:
Expand Down
13 changes: 8 additions & 5 deletions contracts/bridge/.dapprc
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# Make dependencies available
export DAPP_REMAPPINGS=$(cat remappings.txt)
export DAPP_SRC=flat
export DAPP_SRC=src
export DAPP_OUT=out
export DAPP_EVM_VERSION=istanbul
export DAPP_JSON=out/dapp.sol.json

export DAPP_SOLC_VERSION=0.7.6
# If you're getting an "invalid character at offset" error, comment this out.
export DAPP_LINK_TEST_LIBRARIES=0
export DAPP_TEST_VERBOSITY=1
export DAPP_TEST_SMTTIMEOUT=500000

# Optimize your contracts before deploying to reduce runtime execution costs.
Expand All @@ -17,9 +16,13 @@ export DAPP_SKIP_BUILD=
export DAPP_BUILD_OPTIMIZE=1
export DAPP_BUILD_OPTIMIZE_RUNS=999999

if [ "$DEEP_FUZZ" = "true" ]
if [ "$CI" = "true" ]
then
export DAPP_TEST_FUZZ_RUNS=50000 # Fuzz for a long time if DEEP_FUZZ is set to true.
export DAPP_TEST_FUZZ_RUNS=10000
export DAPP_TEST_MAX_ITERATIONS=6
export DAPP_TEST_VERBOSITY=0
else
export DAPP_TEST_FUZZ_RUNS=100 # Only fuzz briefly if DEEP_FUZZ is not set to true.
export DAPP_TEST_FUZZ_RUNS=100
export DAPP_TEST_MAX_ITERATIONS=3
export DAPP_TEST_VERBOSITY=3
fi
238 changes: 124 additions & 114 deletions contracts/bridge/.gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,97 +1,96 @@
test_move_relayer() (gas: 336813)
testFail_enroll_2() (gas: 39427)
test_settle_when_a_relay_and_b_confirm_late_all_slash() (gas: 671394)
test_set_setter() (gas: 2816)
test_settle_when_b_relay_and_c_confirm_at_a_slot() (gas: 711798)
test_assign() (gas: 596711)
test_initial_state() (gas: 12427)
test_set_outbound() (gas: 26445)
testFail_exit_2() (gas: 42353)
test_constructor_args() (gas: 10714)
test_exit() (gas: 64677)
test_add_relayer() (gas: 297662)
test_join() (gas: 105361)
test_settle_when_a_relay_and_a_confirm_at_b_slot() (gas: 712232)
test_settle_when_a_relay_and_b_confirm_late_half_slash() (gas: 691299)
test_settle_when_a_relay_and_b_confirm_at_c_slot() (gas: 690004)
test_enroll() (gas: 300951)
test_settle_when_a_relay_and_b_confirm_at_a_slot() (gas: 711798)
test_settle_when_a_relay_and_b_confirm_late() (gas: 691364)
test_leave() (gas: 136212)
test_settle_when_a_relay_and_confirm_at_a_slot() (gas: 722726)
test_market_status() (gas: 299597)
testFail_exit_3() (gas: 89164)
testFail_enroll_1() (gas: 152967)
testFail_exit_1() (gas: 4050)
test_remove_relayer() (gas: 307936)
test_settle_when_b_relay_and_b_confirm_at_b_slot() (gas: 712190)
test_move_relayer() (gas: 336553)
testFail_enroll_2() (gas: 39404)
test_settle_when_a_relay_and_b_confirm_late_all_slash() (gas: 466689)
test_set_setter() (gas: 2659)
test_settle_when_b_relay_and_c_confirm_at_a_slot() (gas: 466361)
test_assign() (gas: 430851)
test_initial_state() (gas: 12295)
test_set_outbound() (gas: 26456)
test_settle_when_b_relay_and_b_confirm_at_a_slot_late() (gas: 466783)
testFail_exit_2() (gas: 42329)
test_constructor_args() (gas: 5388)
test_exit() (gas: 64675)
test_add_relayer() (gas: 297537)
test_settle_when_a_relay_and_a_confirm_at_a_slot() (gas: 466784)
test_join() (gas: 105157)
test_settle_when_a_relay_and_b_confirm_late_half_slash() (gas: 466783)
test_enroll() (gas: 300673)
test_settle_when_a_relay_and_b_confirm_at_a_slot() (gas: 464554)
test_leave() (gas: 136110)
test_settle_when_a_relay_and_confirm_at_a_slot() (gas: 473889)
test_settle_when_b_relay_and_b_confirm_late_all_slash() (gas: 446811)
test_market_status() (gas: 295737)
testFail_exit_3() (gas: 89139)
testFail_enroll_1() (gas: 152871)
testFail_exit_1() (gas: 4028)
test_remove_relayer() (gas: 307792)
testFail_receive_messages_proof0() (gas: 32231)
testFail_receive_messages_proof1() (gas: 33388)
testFail_receive_messages_proof2() (gas: 33397)
test_constructor_args() (gas: 9536)
test_receive_messages_proof() (gas: 90737)
testFail_receive_messages_proof3() (gas: 33493)
testFail_receive_messages_proof5() (gas: 33555)
test_receive_messages_proof_multi1() (gas: 166377)
testFail_receive_messages_proof4() (gas: 33502)
test_receive_messages_proof_multi0() (gas: 109842)
test_encode_message_key() (gas: 1471)
test_contructor_args() (gas: 2961)
test_send_message() (gas: 58836)
test_move_relayer() (gas: 336967)
testFail_enroll_2() (gas: 39438)
test_settle_when_a_relay_and_b_confirm_late_all_slash() (gas: 678674)
test_set_setter() (gas: 2860)
test_settle_when_b_relay_and_c_confirm_at_a_slot() (gas: 719081)
test_assign() (gas: 604588)
test_initial_state() (gas: 12471)
test_set_outbound() (gas: 26401)
testFail_exit_2() (gas: 42375)
test_constructor_args() (gas: 10499)
test_exit() (gas: 64743)
test_add_relayer() (gas: 298091)
test_join() (gas: 105626)
test_settle_when_a_relay_and_a_confirm_at_b_slot() (gas: 719481)
test_settle_when_a_relay_and_b_confirm_late_half_slash() (gas: 698637)
test_settle_when_a_relay_and_b_confirm_at_c_slot() (gas: 697241)
test_enroll() (gas: 301293)
test_settle_when_a_relay_and_b_confirm_at_a_slot() (gas: 719059)
test_settle_when_a_relay_and_b_confirm_late() (gas: 698616)
test_leave() (gas: 136465)
test_settle_when_a_relay_and_confirm_at_a_slot() (gas: 730119)
test_market_status() (gas: 308036)
testFail_exit_3() (gas: 89186)
testFail_enroll_1() (gas: 153034)
testFail_exit_1() (gas: 4006)
test_remove_relayer() (gas: 308016)
test_settle_when_b_relay_and_b_confirm_at_b_slot() (gas: 719439)
test_move_relayer() (gas: 336685)
testFail_enroll_2() (gas: 39392)
test_settle_when_a_relay_and_b_confirm_late_all_slash() (gas: 467011)
test_settle_when_b_relay_and_c_confirm_at_a_slot() (gas: 467200)
test_assign() (gas: 432251)
test_initial_state() (gas: 12472)
test_settle_when_b_relay_and_b_confirm_at_a_slot_late() (gas: 467055)
testFail_exit_2() (gas: 42352)
test_constructor_args() (gas: 5281)
test_exit() (gas: 64875)
test_add_relayer() (gas: 297683)
test_settle_when_a_relay_and_a_confirm_at_a_slot() (gas: 467056)
test_join() (gas: 105735)
test_settle_when_a_relay_and_b_confirm_late_half_slash() (gas: 467077)
test_enroll() (gas: 300973)
test_settle_when_a_relay_and_b_confirm_at_a_slot() (gas: 465393)
test_leave() (gas: 136255)
test_settle_when_a_relay_and_confirm_at_a_slot() (gas: 475016)
test_settle_when_b_relay_and_b_confirm_late_all_slash() (gas: 447089)
test_market_status() (gas: 304236)
testFail_exit_3() (gas: 89207)
testFail_enroll_1() (gas: 152915)
testFail_exit_1() (gas: 3984)
test_remove_relayer() (gas: 307741)
testFail_receive_messages_proof0() (gas: 32239)
testFail_receive_messages_proof1() (gas: 33425)
testFail_receive_messages_proof2() (gas: 33434)
test_constructor_args() (gas: 7176)
test_receive_messages_proof() (gas: 88933)
testFail_receive_messages_proof3() (gas: 33530)
testFail_receive_messages_proof5() (gas: 33592)
test_receive_messages_proof_multi1() (gas: 164539)
testFail_receive_messages_proof4() (gas: 33539)
test_receive_messages_proof_multi0() (gas: 107940)
test_encode_message_key() (gas: 1449)
test_contructor_args() (gas: 1627)
test_send_message() (gas: 58873)
test_message_hash() (gas: 784)
testFail_receive_multi_messages_delivery_proof0() (gas: 179365)
testFail_receive_messages_delivery_proof0() (gas: 60813)
test_constructor_args() (gas: 8709)
testFail_receive_messages_delivery_proof4() (gas: 61267)
test_receive_multi_messages_delivery_proof1() (gas: 197313)
testFail_receive_messages_delivery_proof5() (gas: 61173)
test_send_multi_message() (gas: 170207)
testFail_receive_messages_delivery_proof2() (gas: 60859)
testFail_receive_messages_delivery_proof1() (gas: 60881)
test_receive_messages_delivery_proof() (gas: 72336)
testFail_receive_messages_delivery_proof3() (gas: 60929)
test_receive_multi_messages_delivery_proof0() (gas: 175062)
test_encode_message_key() (gas: 1483)
test_contructor_args() (gas: 2961)
testFail_receive_multi_messages_delivery_proof0() (gas: 179199)
testFail_receive_messages_delivery_proof0() (gas: 60853)
test_constructor_args() (gas: 8686)
testFail_receive_messages_delivery_proof4() (gas: 61298)
test_receive_multi_messages_delivery_proof1() (gas: 196861)
testFail_receive_messages_delivery_proof5() (gas: 61204)
test_send_multi_message() (gas: 170327)
testFail_receive_messages_delivery_proof2() (gas: 60899)
testFail_receive_messages_delivery_proof1() (gas: 60921)
testFail_too_many_pending_messages() (gas: 1046165)
test_receive_messages_delivery_proof() (gas: 72090)
testFail_receive_messages_delivery_proof3() (gas: 60969)
test_receive_multi_messages_delivery_proof0() (gas: 174896)
test_encode_message_key() (gas: 1461)
test_contructor_args() (gas: 1627)
testFail_add_g1() (gas: 41338)
test_encode_next_validator_set() (gas: 8910)
test_hash() (gas: 3693)
test_fork_data_hash() (gas: 1200)
test_compute_signing_root() (gas: 12623)
test_compute_signing_root() (gas: 12711)
test_signing_data_hash() (gas: 1213)
test_is_valid_merkle_branch_case1() (gas: 6243)
test_is_valid_merkle_branch_case0() (gas: 6265)
test_beacon_block_header_hash() (gas: 61765)
test_beacon_block_header_hash() (gas: 62293)
test_compute_signing_root2() (gas: 1101)
test_to_little_endian_64() (gas: 479)
test_default_hash() (gas: 10511)
test_sync_committee_hash() (gas: 5072713)
test_to_little_endian_64() (gas: 523)
test_default_hash() (gas: 10599)
test_sync_committee_hash() (gas: 5072712)
test_hash_rlp_with_chain_id_block_header() (gas: 304413)
test_hash_block_header() (gas: 51685)
test_hash_rlp_block_header() (gas: 294495)
Expand All @@ -100,30 +99,30 @@ test_constants() (gas: 1281)
test_decode_message_key() (gas: 876)
test_hash2() (gas: 4791)
test_hash() (gas: 11935)
test_verify_single_storage_proof() (gas: 344601)
test_storage_proof() (gas: 932453)
test_message_proof() (gas: 720342)
test_verify_single_storage_proof() (gas: 344586)
test_storage_proof() (gas: 932393)
test_message_proof() (gas: 720297)
test_default_hash() (gas: 1643)
test_constants() (gas: 1203)
test_hash() (gas: 4504)
test_recover_creator() (gas: 73397)
test_constructor_args() (gas: 126059)
testFail_import_finalized_epoch_header() (gas: 6349)
test_extract_authorities() (gas: 33958)
test_import_finalized_epoch_header() (gas: 2469969)
test_recover_creator() (gas: 69938)
test_constructor_args() (gas: 93532)
testFail_import_finalized_epoch_header() (gas: 5726)
test_extract_authorities() (gas: 18552)
test_import_finalized_epoch_header() (gas: 1306709)
test_recover_creator() (gas: 73442)
test_constructor_args() (gas: 125509)
testFail_import_finalized_epoch_header() (gas: 6351)
test_extract_authorities() (gas: 33936)
test_import_finalized_epoch_header() (gas: 2469421)
test_recover_creator() (gas: 69983)
test_constructor_args() (gas: 93224)
testFail_import_finalized_epoch_header() (gas: 5728)
test_extract_authorities() (gas: 18530)
test_import_finalized_epoch_header() (gas: 1306403)
test_fast_aggregate_verify() (gas: 122)
test_verify_single_storage_proof() (gas: 122)
test_verify_multi_storage_proof() (gas: 144)
test_prove_one_leave() (gas: 135349)
testFail_prove_empty() (gas: 4318)
testFail_prove_three_leaves_with_wrong_pos() (gas: 344673)
test_prove_two_leaves() (gas: 255970)
test_prove_three_leaves() (gas: 387492)
test_prove_one_leave() (gas: 135395)
testFail_prove_empty() (gas: 4364)
testFail_prove_three_leaves_with_wrong_pos() (gas: 344719)
test_prove_two_leaves() (gas: 256062)
test_prove_three_leaves() (gas: 387630)
test_empty_commitment() (gas: 3786)
testFail_complete_signature_commitment() (gas: 119466)
test_new_signature_commitment() (gas: 85539)
Expand All @@ -139,18 +138,29 @@ testFail_add_relayer_with_wrong_threshold() (gas: 55828)
test_swap_relayer_hash() (gas: 1589)
test_remove_relayer() (gas: 73383)
test_swap_relayer() (gas: 60120)
test_import_message_commitment() (gas: 58567)
test_import_message_commitment() (gas: 58624)
test_message_commitment_hash2() (gas: 978)
test_message_commitment_hash() (gas: 977)
test_hash_body() (gas: 43274)
test_constructor_args() (gas: 211)
test_import_finalized_header() (gas: 3184718)
test_import_next_sync_committee() (gas: 8551265)
test_import_latest_execution_payload_state_root() (gas: 3220512)
test_constructor_args() (gas: 189)
test_import_finalized_header() (gas: 2976093)
test_sum_sync_committee_bits() (gas: 1029)
test_import_next_sync_committee() (gas: 8342599)
test_import_latest_execution_payload_state_root() (gas: 3011871)
test_import_finalized_header() (gas: 3100337)
test_sum_sync_committee_bits() (gas: 1047)
test_hash_execution_payload() (gas: 22834)
test_import_next_sync_committee() (gas: 8985305)
test_import_latest_execution_payload_state_root() (gas: 3168744)
test_hash_body() (gas: 43274)
test_constructor_args() (gas: 211)
test_import_finalized_header() (gas: 2910756)
test_sum_sync_committee_bits() (gas: 1047)
test_hash_execution_payload() (gas: 22834)
test_import_next_sync_committee() (gas: 8800997)
test_import_latest_execution_payload_state_root() (gas: 2979163)
test_hash_body() (gas: 43263)
test_constructor_args() (gas: 233)
test_import_finalized_header() (gas: 3143100)
test_hash_execution_payload() (gas: 22846)
testFail_import_next_sync_committee() (gas: 5395376)
test_import_latest_execution_payload_state_root() (gas: 3211411)
test_random_n_bits_with_prior_check() (gas: 13872)
test_clean() (gas: 1118)
test_count_set_bits() (gas: 1344)
Expand Down Expand Up @@ -182,8 +192,8 @@ testFail_bits_highest_bit_set_throws_bit_field_is_zero() (gas: 244)
test_bits_lowest_bit_set_all_higher_set() (gas: 1236)
test_recover() (gas: 4119)
testFail_recover() (gas: 10030)
test_get_power_of_two_ceil() (gas: 4001)
test_log_2() (gas: 8463)
test_get_power_of_two_ceil() (gas: 4079)
test_log_2() (gas: 9037)
test_decode_uint_compact() (gas: 3423)
test_decode_uint256() (gas: 10942)
testFail_decode_uint_compact() (gas: 663)
Expand Down
3 changes: 2 additions & 1 deletion contracts/bridge/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ test :; dapp test # --ffi # enable if you need the `ffi` cheat code on HEVM
clean :; dapp clean
lint :; yarn run lint
doc :; yarn run docs
cov :; @./bin/coverage.sh
audit :; @./bin/audit.sh
flatten :; @./bin/flatten.sh
estimate :; @./bin/estimate-gas.sh ${contract}
Expand All @@ -47,4 +48,4 @@ migrate-test :; @./bin/migrate-test.sh
migrate-prod :; @./bin/migrate-prod.sh

# verify on Etherscan
verify:; ETH_RPC_URL=$(call network,$(network_name)) dapp verify-contract src/Greeter.sol:Greeter $(contract_address)
verify :; ETH_RPC_URL=$(call network,$(network_name)) dapp verify-contract src/Greeter.sol:Greeter $(contract_address)
Loading

0 comments on commit b06a437

Please sign in to comment.