MCPcopy Create free account
hub / github.com/ccxt/ccxt / testRawencode

Function testRawencode

ts/src/test/base/test.rawencode.ts:6–39  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4import ccxt from '../../../ccxt.js';
5
6function testRawencode () {
7
8 const exchange = new ccxt.Exchange ({
9 'id': 'sampleexchange',
10 });
11
12
13 // todo: add sort
14 // todo: add nulls
15 const dict2 = {
16 'a': 1,
17 'b': '+&',
18 };
19 // as key-order not preserved, expect mixed orde
20 const expected2a = 'a=1&b=+&';
21 const expected2b = 'b=+&&a=1';
22 const result2 = exchange.rawencode (dict2);
23
24 assert (result2 === expected2a || result2 === expected2b, 'rawencode: expected ' + expected2a + ' or ' + expected2b + ' but got ' + result2);
25
26 // todo: fails in python, like: 'AssertionError'> rawencode: expected a=1&b[c]=2&b[something]=+&&d[0]=1&d[1]=2 but got a=1&b={'c': 2, 'something': '+&'}&d=[1, 2]
27 //
28 // const dict2 = {
29 // 'a': 1,
30 // 'b': {
31 // 'c': 2,
32 // 'something': '+&'
33 // },
34 // 'd': [ 1, 2 ],
35 // };
36 // const expected2 = 'a=1&b[c]=2&b[something]=+&&d[0]=1&d[1]=2';
37
38 // assert (exchange.rawencode (dict2) === expected2, 'rawencode: expected ' + expected2 + ' but got ' + exchange.rawencode (dict2));
39}
40
41export default testRawencode;

Callers 1

baseTestsInitFunction · 0.70

Calls 2

rawencodeMethod · 0.95
assertFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…