-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: tests for fetch(Cross|Isolated)BorrowRate(s)
- Loading branch information
1 parent
5bb906f
commit 2bbc9ba
Showing
4 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Exchange } from "../../../../ccxt"; | ||
import testSharedMethods from './test.sharedMethods.js'; | ||
|
||
function testCrossBorrowRate (exchange: Exchange, skippedProperties: object, method: string, entry: object, requestedCode: string) { | ||
const format = { | ||
'info': {}, // Or [] | ||
'currency': 'USDT', | ||
'timestamp': 1638230400000, | ||
'datetime': '2021-11-30T00:00:00.000Z', | ||
'rate': exchange.parseNumber ('0.0006'), // Interest rate | ||
'period': 86400000, // Amount of time the interest rate is based on in milliseconds | ||
}; | ||
testSharedMethods.assertStructure (exchange, skippedProperties, method, entry, format); | ||
testSharedMethods.assertTimestampAndDatetime (exchange, skippedProperties, method, entry); | ||
testSharedMethods.assertCurrencyCode (exchange, skippedProperties, method, entry, entry['currency'], requestedCode); | ||
// | ||
// assert (borrowRate['period'] === 86400000 || borrowRate['period'] === 3600000) // Milliseconds in an hour or a day | ||
testSharedMethods.assertGreater (exchange, skippedProperties, method, entry, 'period', '0'); | ||
testSharedMethods.assertGreater (exchange, skippedProperties, method, entry, 'rate', '0'); | ||
} | ||
|
||
export default testCrossBorrowRate; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Exchange } from "../../../../ccxt"; | ||
import testSharedMethods from './test.sharedMethods.js'; | ||
|
||
function testFetchIsolatedBorrowRate (exchange: Exchange, skippedProperties: object, method: string, entry: object, requestedCode: string) { | ||
const format = { | ||
'info': {}, // Or [] | ||
'symbol': 'BTC/USDT', | ||
'base': 'BTC', | ||
'baseRate': exchange.parseNumber ('0.0006'), // Interest rate, | ||
'quote': 'USDT', | ||
'quoteRate': exchange.parseNumber ('0.0006'), // Interest rate, | ||
'timestamp': 1638230400000, | ||
'datetime': '2021-11-30T00:00:00.000Z', | ||
'period': 86400000, // Amount of time the interest rate is based on in milliseconds | ||
}; | ||
testSharedMethods.assertStructure (exchange, skippedProperties, method, entry, format); | ||
testSharedMethods.assertTimestampAndDatetime (exchange, skippedProperties, method, entry); | ||
testSharedMethods.assertCurrencyCode (exchange, skippedProperties, method, entry, entry['base'], requestedCode); | ||
testSharedMethods.assertCurrencyCode (exchange, skippedProperties, method, entry, entry['quote'], requestedCode); | ||
testSharedMethods.assertSymbol (exchange, skippedProperties, method, entry, 'symbol', requestedCode); | ||
// | ||
// assert (borrowRate['period'] === 86400000 || borrowRate['period'] === 3600000) // Milliseconds in an hour or a day | ||
testSharedMethods.assertGreater (exchange, skippedProperties, method, entry, 'period', '0'); | ||
testSharedMethods.assertGreater (exchange, skippedProperties, method, entry, 'baseRate', '0'); | ||
testSharedMethods.assertGreater (exchange, skippedProperties, method, entry, 'quoteRate', '0'); | ||
} | ||
|
||
export default testFetchIsolatedBorrowRate; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Exchange } from "../../../ccxt"; | ||
import testSharedMethods from './base/test.sharedMethods.js'; | ||
import testCrossBorrowRate from './base/test.crossBorrowRate.js'; | ||
|
||
async function testFetchCrossBorrowRates (exchange: Exchange, skippedProperties: object, symbol: string) { | ||
const method = 'fetchCrossBorrowRates'; | ||
const borrowRates = await exchange.fetchCrossBorrowRates (symbol); | ||
const codes = Object.keys (borrowRates); | ||
testSharedMethods.assertNonEmtpyArray (exchange, skippedProperties, method, codes); | ||
for (let i = 0; i < codes.length; i++) { | ||
const code = codes[i]; | ||
testCrossBorrowRate (exchange, skippedProperties, method, borrowRates[code], symbol); | ||
} | ||
} | ||
|
||
export default testFetchCrossBorrowRates; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Exchange } from "../../../ccxt"; | ||
import testSharedMethods from './base/test.sharedMethods.js'; | ||
import testIsolatedBorrowRate from './base/test.isolatedBorrowRate.js'; | ||
|
||
async function testFetchIsolatedBorrowRates (exchange: Exchange, skippedProperties: object, symbol: string) { | ||
const method = 'fetchIsolatedBorrowRates'; | ||
const borrowRates = await exchange.fetchIsolatedBorrowRates (symbol); | ||
const codes = Object.keys (borrowRates); | ||
testSharedMethods.assertNonEmtpyArray (exchange, skippedProperties, method, codes); | ||
for (let i = 0; i < codes.length; i++) { | ||
const code = codes[i]; | ||
testIsolatedBorrowRate (exchange, skippedProperties, method, borrowRates[code], symbol); | ||
} | ||
} | ||
|
||
export default testFetchIsolatedBorrowRates; |