-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathtest_contract.js
More file actions
31 lines (30 loc) · 1.46 KB
/
test_contract.js
File metadata and controls
31 lines (30 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
* Tests for the Contract helper
* Set config file in /config.config.js manually because mocha.js overwrites process.arg
*/
import C from '../src/controller/contract';
const assert = require('assert');
describe('Contract', () => {
const rbtcAddress = C.contractTokenRBTC._address.toLowerCase();
const tokens = [
['USDT', C.contractTokenUSDT._address.toLowerCase()],
['DOC', C.contractTokenSUSD._address.toLowerCase()],
]
describe('#getLiquidityPoolByTokens', () => {
tokens.forEach(([symbol, tokenAddress]) => {
it(`Should get the liquidity pool for RBTC and ${symbol}`, async () => {
const liquidityPool = await C.getLiquidityPoolByTokens(rbtcAddress, tokenAddress);
assert(liquidityPool);
const contractPrimaryToken = await liquidityPool.methods.primaryReserveToken().call();
assert(contractPrimaryToken.toLowerCase() === rbtcAddress);
});
it(`Should get the liquidity pool for ${symbol} and RBTC`, async () => {
const liquidityPool = await C.getLiquidityPoolByTokens(rbtcAddress, tokenAddress);
assert(liquidityPool);
// primary token is still RBTC. not that it matters much
const contractPrimaryToken = await liquidityPool.methods.primaryReserveToken().call();
assert(contractPrimaryToken.toLowerCase() === rbtcAddress);
});
});
});
});