test('config is merged correctly', async t => { const conf1 = config.generateConfig() t.deepEqual(conf1, config.DEFAULT_CONFIG) const modifier = { exclude: ['deps/'], custom_key: 'test' } const conf2 = config.generateConfig(modifier) t.deepEqual(conf2, deepmerge(config.DEFAULT_CONFIG, modifier)) })
constructor(config = {}, options = {}) { super(); const { apiKey, apiSecret, passphrase, unique_id, otc_id, spot_id } = config; this.config = config; this.options = deepmerge(defaultOptions, options); this.passphrase = passphrase; this.apiSecret = apiSecret; this.apiKey = apiKey; this.otc_id = otc_id; this.spot_id = spot_id; this.unique_id = unique_id; this.proxy = isProxy ? 'http://127.0.0.1:1087' : null; this.resp_time_n = 500; }
function create (userFunctions, userConfig) { const opts = deepmerge(defaults, userConfig) const seedPrefix = opts.randomSeed ? crypto.randomBytes(16).toString('hex') : opts.seedPrefix const seedNumber = (opts.seedNumber !== undefined) ? opts.seedNumber : 0 var events = new EventEmitter() return { events, run } async function run () { for (let i = 0; i < opts.numIterations; i++) { const fuzzer = new GenericFuzzer(userFunctions, { ...userConfig, seed: seedPrefix, seedNumber: seedNumber + i }) await fuzzer.setup() events.emit('progress') await fuzzer.run() } } }
function formatSwapPosition(res) { if (!res) return null; const resMap = {}; _.forEach(res, (l) => { const { margin_mode, timestamp, holding, instrument_id: _instrument_id } = l; const time = new Date(timestamp); _.forEach(holding, (l) => { const instrument_id = l.instrument_id || _instrument_id; const old = resMap[instrument_id] || { // long_amount: 0, // long_margin: 0, // short_amount: 0, // short_margin: 0 }; const _l = { ..._formatSwapPosition({ instrument_id, ...l }), margin_mode, time }; const newl = deepmerge(old, _l); resMap[instrument_id] = newl; }); }); return _.values(resMap); }
this.fields[key] = this.mergeArrayDeduped(existing, value); } else if (isObject(value) && isObject(existing)) { this.fields[key] = deepmerge(existing, value, { arrayMerge: this.mergeArrayDeduped });
imageSettings = deepmerge(imageSettings, options[preset], { arrayMerge: overwriteMerge, });
this.fields[key] = this.mergeArrayDeduped(existing, value); } else if (isObject(value) && isObject(existing)) { this.fields[key] = deepmerge(existing, value, { arrayMerge: this.mergeArrayDeduped });
imageSettings = deepmerge(imageSettings, options[preset], { arrayMerge: overwriteMerge, });