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

feat: Fixed unit tests and add tests for the new federation version #379

Merged
merged 2 commits into from
Jan 24, 2024

Conversation

gsoares85
Copy link
Collaborator

Title of pull request

The pull request should be described here

Description

  • Describe here your pull request modifications
  • It could be more than one thing

How to Test

  • Run both ganache-cli
  • Enter into the bridge directory and run all the tests

Case 1

  1. Go to bridge directory
$~ cd bridge
  1. Run all the tests
$~ npm run test

Expected Result

  • It should pass the test
    image
  1. Run the first ganache-cli
$~ npm run ganache
  1. Open another shell and run the ganache mirror
$~ npm run ganache-mirror
  1. Go to the federator directory
$~ cd ../federator
  1. Run the integration test
$~ npm run integrationTest

Expected Result

  • It should pass the test
    image
  1. Run the integration test
$~ npm run integrationTest

Expected Result

  • It should pass the test
    image

Case N...

Checklist

Bridge Directory cd bridge

  • [] Lint is clean npm run lint
  • [] Test is passing npm run test
  • [] Contracts are compiling npm run compile

Federator Directory cd federator

  • [] Lint is clean npm run lint
  • [] Test is passing npm run test
  • [] Typescript is compiling npm run build

@@ -75,7 +75,7 @@ contract('Bridge Multichain Deploy Check', async function (accounts) {
const bridgeV4Implementation = new web3.eth.Contract(this.bridgeV4.abi, bridgeProxy.address);

result = await bridgeV4Implementation.methods.version().call();
assert.equal(result, 'v4');
assert.equal(result, 'v3');
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't understand this change, if its v4 why is v3 expected?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There is no V4 for bridge, this was wrong in the tests. I don't know if they planed to do it in the past but there is not Bridge V4

logIndex
);

require(votes[transactionId][_msgSender()] == false, "Federation: Federator already vote for this transaction");
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we are using the require now, what is the purpose of keep returning a boolean? there are no cases of returning false, I would go full with require or full with boolean but mixing them is confusing

{from: anAccount}
),
truffleAssertions.ErrorType.REVERT
);
});

it('should fail if different array size', async function() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you explain why this test is removed? (just to have context)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because there is no array parameter in the contract more, there was in a old version.

@@ -446,8 +408,14 @@ contract('FederationV2', async function (accounts) {
await this.allowTokens.setToken(originalTokenAddress, typeId);
this.sideTokenFactory = await SideTokenFactory.new();
this.bridge = await Bridge.new();
await this.bridge.methods['initialize(address,address,address,address)'](deployer, this.federators.address,
this.allowTokens.address, this.sideTokenFactory.address);
await this.bridge.methods['initialize(address,address,address,address,string)']
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why this signature changes if the only contract in the PR with changes is federation? was this test outdated?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same as before, they updated the contract but didn't updated the tests.

crossEvent.logIndex,
chains.ETHEREUM_MAIN_NET_CHAIN_ID,
chains.HARDHAT_TEST_NET_CHAIN_ID,
crossEvent.logIndex
Copy link
Collaborator

Choose a reason for hiding this comment

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

this was outdated right? I don't see in FederationV2 the chain ids arguments in this event

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Most of my changes on the tests was to remove outdated values

@@ -140,7 +140,7 @@ contract('Bridge upgrade test', async (accounts) => {
const newProxy = new web3.eth.Contract(BridgeV4.abi, this.proxyBridge.options.address);

result = await newProxy.methods.version().call();
assert.equal(result, 'v4');
assert.equal(result, 'v3');
Copy link
Collaborator

Choose a reason for hiding this comment

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

same question as before

Copy link
Collaborator

Choose a reason for hiding this comment

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

all the fixes related to bridge functions signatures are because this tests were outdated?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes.

Copy link
Collaborator

@Luisfc68 Luisfc68 left a comment

Choose a reason for hiding this comment

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

All good except for the point that I mentioned about returning bool vs using require. Also pls confirm me if the tests that I asked about have changes because they were outdate or if it is related to the PR


function changeRequirement(uint _required) external onlyOwner validRequirement(members.length, _required)
{
require(_required >= 2, "Federation: Requires at least 2");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you please help to understand this?

Copy link

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.9% Duplication on New Code

See analysis details on SonarCloud

@gsoares85 gsoares85 requested a review from Luisfc68 January 24, 2024 09:03
@gsoares85 gsoares85 merged commit c775a35 into QA-Test Jan 24, 2024
3 checks passed
@gsoares85 gsoares85 deleted the feature/GBI-1601-upgradeFederation branch January 24, 2024 15:14
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.

3 participants