This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Install Hardhat and run all tests: | |
npm add --save-dev hardhat | |
yarn install // Delete yarn.lock if an error occurs | |
yarn run test | |
For specific file: | |
yarn test ./test/SwapMath.spec.ts | |
sources: | |
- https://docs.uniswap.org/contracts/v3/guides/local-environment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Test to evaluate rounding behavior and zeros | |
#[test] | |
fn test_division_round_with_negative_result() { | |
// -10/ 3 = 0 | |
let a = IntegerTrait::<i256>::new(10, true); | |
let b = IntegerTrait::<i256>::new(3, false); | |
let (q, r) = a.div_rem(b); | |
assert(q.mag == 3 && r.mag == 1, '-10 / 3 = (-3, -1)'); // should be (-3, 1)? | |
assert(q.sign == true && r.sign == true, '(neg, neg)'); |