Skip to content
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

Improve beefy tests #901

Merged
merged 10 commits into from
Jul 27, 2023
Merged

Improve beefy tests #901

merged 10 commits into from
Jul 27, 2023

Conversation

yrong
Copy link
Contributor

@yrong yrong commented Jul 25, 2023

Resolves: SNO-576

@codecov
Copy link

codecov bot commented Jul 25, 2023

Codecov Report

❗ No coverage uploaded for pull request base (proxy-contracts@a2c96f8). Click here to learn what that means.
Patch has no changes to coverable lines.

Additional details and impacted files
@@                Coverage Diff                 @@
##             proxy-contracts     #901   +/-   ##
==================================================
  Coverage                   ?   68.43%           
==================================================
  Files                      ?       42           
  Lines                      ?     1774           
  Branches                   ?       72           
==================================================
  Hits                       ?     1214           
  Misses                     ?      541           
  Partials                   ?       19           
Flag Coverage Δ
solidity 73.31% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yrong
Copy link
Contributor Author

yrong commented Jul 25, 2023

Gas consumed increased as we change test more close to real workflow(e.g. add createFinalBitfield in each test) and not a issue.

testSubmitWithHandoverFailWithoutPrevRandao() (gas: -2264 (-0.405%))
testSubmitFailWithoutPrevRandao() (gas: -2177 (-0.407%))
testSubmitFailForPrevRandaoTooEarlyOrTooLate() (gas: -1450 (-0.690%))
testSubmitFailForPrevRandaoCapturedMoreThanOnce() (gas: -1959 (-0.727%))
testScaleEncodeCommit() (gas: 281 (0.872%))
testSubmitWithHandoverFailStaleCommitment() (gas: 79700 (10.195%))
testSubmitWithHandover() (gas: 68945 (10.315%))
testSubmitFailWithStaleCommitment() (gas: 79563 (10.499%))
testSubmitFailInvalidSignature() (gas: 76694 (13.187%))
testSubmitFailWithInvalidBitfield() (gas: 76222 (13.628%))
testSubmitFailValidatorNotInBitfield() (gas: 77562 (13.640%))
Overall gas change: 451117 (8.166%)

@yrong yrong marked this pull request as ready for review July 26, 2023 01:20
@yrong yrong requested review from doubledup and vgeddes July 26, 2023 03:45
Copy link
Collaborator

@vgeddes vgeddes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Let's merge this in.

I added comments about the next task, once you've merged in.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Next steps - to implement in a new ticket - let's move this script and helpers.ts to a new package under core/packages. We can call the package test-helpers or something like that.

The goal is to remove javascript stuff from the contracts project.

import { ValidatorSet, createRandomSubset, readSetBits } from "./helpers"
import { BigNumber, ethers } from "ethers"
import fs from "fs"
import type { BeefyClient } from "../types/BeefyClient"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a new package under core/packages with our contract bindings. Can call the package directory contract-types, and the package name @snowbridge/contract-types.

You'll need to include this script command in the new package:

"build:types": "typechain --target ethers-v5 'out/**/!(*.t|test).sol/!(*.abi).json' --out-dir types",

Then this dependency should change to:

import type { BeefyClient } from "@snowbridge/contract-types"

@yrong yrong merged commit d425a58 into proxy-contracts Jul 27, 2023
1 check passed
@yrong yrong deleted the ron/improve-beefy-tests branch July 27, 2023 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants