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

test: add extreme case tests #971

Merged
merged 1 commit into from
Aug 26, 2024
Merged

Conversation

b00ste
Copy link
Member

@b00ste b00ste commented Aug 22, 2024

What does this PR introduce?

🧪 Tests

Add tests:

  • Make sure follow/unfollow cannot be reverted by return bomb attack
  • Make sure follow/unfollow cannot be reverted by an infinite loop
  • Make sure follow/unfollow cannot be reverted when contract self destructs on interface check

PR Checklist

  • Wrote Tests
  • Wrote & Generated Documentation (readme/natspec/dodoc)
  • Ran npm run lint && npm run lint:solidity (solhint)
  • Ran npm run format (prettier)
  • Ran npm run build
  • Ran npm run test

@b00ste b00ste force-pushed the test-lsp26-for-return-bomb-attack branch from e8d390e to 16db798 Compare August 22, 2024 11:17
@b00ste b00ste changed the title test: add tests to make sure follow/unfollow cannot be reverted by return bomb test: add extreme case tests Aug 22, 2024
Copy link
Member

@skimaharvey skimaharvey left a comment

Choose a reason for hiding this comment

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

LG

@b00ste b00ste force-pushed the test-lsp26-for-return-bomb-attack branch from 16db798 to c71b9f3 Compare August 22, 2024 11:46
Copy link
Member

@JeneaVranceanu JeneaVranceanu left a comment

Choose a reason for hiding this comment

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

Whoami to approve? Looks good in the eyes of an amateur. Something new to learn 🙂

});
});

describe('testing follow/unfollow a contract that has an infinite loop in urd', () => {
Copy link
Member

Choose a reason for hiding this comment

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

So.. a newbie question, how does it pass with this infinite loop running?
I see we get to

ILSP1UniversalReceiver(addr).universalReceiver(
                    _TYPEID_LSP26_FOLLOW,
                    abi.encodePacked(msg.sender)
                )

In the LSP26 contract and how does it not fail meaning the loop doesn't prevent transaction from failing letting the user to follow/unfollow?

Copy link
Member Author

Choose a reason for hiding this comment

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

The external call to the contract that has the unviersalReceiver function with an infinite loop reverts, but due to the fact that we call that function using try/catch and we don't do anything in the catch, it does not revert while following or unfollowing someone. Usually you would catch the revert in the catch block and do what you need to from there. In our case we want to make sure we notify yet never revert.

@b00ste b00ste merged commit 38beca5 into develop Aug 26, 2024
2 checks passed
@b00ste b00ste deleted the test-lsp26-for-return-bomb-attack branch August 26, 2024 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants