keep-core icon indicating copy to clipboard operation
keep-core copied to clipboard

Unit test for ECDSA DKG challenge and TokenStaking contract failing on slashing

Open pdyraga opened this issue 3 years ago • 1 comments

See this conversation.

When working on https://github.com/keep-network/keep-core/pull/2850 and replacing StakingStub with a real T TokenStaking for tests, one unit test covering challangeDkgResult had to be removed. challengeDkgResult does not revert if slashing in TokenStaking does revert. It makes sense because it is better to do not slash than to let malicious DKG result be accepted. Testing this behavior is complicated though.

From one side we are trying to test with a real TokenStaking contract and from the other, we are trying to force it to behave in a way it is never behaving.

Using Smock mocks requires setting up half of the world that is already set up in index.ts. Altering index.ts and making it way more complicated for one test feels wrong. Replacing TokenStaking with some stub extending TokenStaking for all tests sucks as well - the entire point is to test against a real contract instead of hoping the inheriting contract does not modify some behavior.

Blocked by https://github.com/defi-wonderland/smock/issues/101

pdyraga avatar Mar 15 '22 15:03 pdyraga

It depends on https://github.com/defi-wonderland/smock/issues/101

nkuba avatar Mar 29 '22 12:03 nkuba