-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.test.js.map
1 lines (1 loc) · 49.3 KB
/
index.test.js.map
1
{"version":3,"sources":["../src/index.test.js"],"names":["Index","proxyquire","noCallThru","load","sleep","time","Promise","resolve","setTimeout","createDeferredStub","observable","sinon","stub","returns","subscribe","handler","test","afterEach","always","restore","t","plan","id","result","instanceStub","rpc","sendAndObserveResponse","AppProxyHandler","get","value","is","true","calledOnceWith","networkDetails","type","networkFn","AppProxy","prototype","network","jsonrpc","sendAndObserveResponses","call","deepEqual","truthy","accountsFn","accounts","currentApp","appAddress","appId","appImplementationAddress","identifier","isForwarder","kernelAddress","name","currentAppFn","icon","undefined","initialApps","endApps","concat","installedAppsFn","installedApps","emitIndex","forEach","app","fail","identifyFn","identify","send","pathFn","path","requestPathFn","requestPath","eventsFn","events","fromBlock","externalFn","external","observableEvents","jsonInterfaceStub","eventsObservable","observableCall","constant","callResult","grantPermission","observableIntent","intentResult","add","stateFn","state","stateObservable","Subject","counter","next","storeFn","store","cache","getCache","pastEvents","web3Eth","withArgs","reducer","action","actionHistory","event","push","payload","blockNumber","callFn","describeScriptFn","describeScript","web3EthFn","registerAppMetadataFn","registerAppMetadata","getCall","args","queryAppMetadataFn","queryAppMetadata","from","to","dataId","cid","getAppMetadataFn","getAppMetadata","newActionFn","newForwardedAction","updateActionFn","updateForwardedAction","instanceStub2","getFwdActionsFn","getForwardedActions","returnValues","triggerFn","trigger","testprop"],"mappings":";;;;AAAA;;AACA;;AACA;;AACA;;AAEA,MAAMA,KAAK,GAAGC,oBAAWC,UAAX,GAAwBC,IAAxB,CAA6B,SAA7B,EAAwC;AACpD,2BAAyB;AAD2B,CAAxC,CAAd;;AAIA,eAAeC,KAAf,CAAsBC,IAAtB,EAA4B;AAC1B,SAAO,IAAIC,OAAJ,CAAYC,OAAO,IAAIC,UAAU,CAACD,OAAD,EAAUF,IAAV,CAAjC,CAAP;AACD;;AAED,SAASI,kBAAT,CAA6BC,UAA7B,EAAyC;AACvC,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YAAY,GAAG;AACnBC,IAAAA,GAAG,EAAE;AACH2C,MAAAA,IAAI,EAAEzD,eAAMC,IAAN;AADH;AADc,GAArB,CAJwD,CASxD;;AACAwH,EAAAA,SAAS,CAAC3F,IAAV,CAAejB,YAAf,EAA6B,aAA7B,EAA4C;AAAE8G,IAAAA,QAAQ,EAAE;AAAZ,GAA5C,EAVwD,CAWxD;;AACAlH,EAAAA,CAAC,CAACU,EAAF,CAAKN,YAAY,CAACC,GAAb,CAAiB2C,IAAjB,CAAsB8C,OAAtB,CAA8B,CAA9B,EAAiCC,IAAjC,CAAsC,CAAtC,CAAL,EAA+C,SAA/C;AACA/F,EAAAA,CAAC,CAACsB,SAAF,CAAYlB,YAAY,CAACC,GAAb,CAAiB2C,IAAjB,CAAsB8C,OAAtB,CAA8B,CAA9B,EAAiCC,IAAjC,CAAsC,CAAtC,CAAZ,EAAsD,CAAC,aAAD,EAAgB;AAAEmB,IAAAA,QAAQ,EAAE;AAAZ,GAAhB,CAAtD;AACD,CAdD","sourcesContent":["import test from 'ava'\nimport sinon from 'sinon'\nimport proxyquire from 'proxyquire'\nimport { defer, from, of, Subject } from 'rxjs'\n\nconst Index = proxyquire.noCallThru().load('./index', {\n '@aragon/rpc-messenger': {}\n})\n\nasync function sleep (time) {\n return new Promise(resolve => setTimeout(resolve, time))\n}\n\nfunction createDeferredStub (observable) {\n return sinon.stub().returns(defer(() => observable))\n}\n\nfunction subscribe (observable, handler) {\n // Mimic an async delay to test the deferred behaviour\n sleep(10)\n observable.subscribe(handler)\n}\n\ntest.afterEach.always(() => {\n sinon.restore()\n})\n\ntest('should send intent when the method does not exist in target', t => {\n t.plan(2)\n // arrange\n const observable = of({\n id: 'uuid1',\n result: 10\n })\n const instanceStub = {\n rpc: {\n // Mimic behaviour of @aragon/rpc-messenger\n sendAndObserveResponse: createDeferredStub(observable)\n }\n }\n // act\n const result = Index.AppProxyHandler.get(instanceStub, 'add')(5)\n // assert\n subscribe(result, value => {\n t.is(value, 10)\n })\n t.true(instanceStub.rpc.sendAndObserveResponse.calledOnceWith('intent', ['add', 5]))\n})\n\ntest('should return the network details as an observable', t => {\n t.plan(2)\n // arrange\n const networkDetails = {\n id: 4,\n type: 'rinkeby'\n }\n const networkFn = Index.AppProxy.prototype.network\n const observable = of({\n jsonrpc: '2.0',\n id: 'uuid1',\n result: networkDetails\n })\n const instanceStub = {\n rpc: {\n // Mimic behaviour of @aragon/rpc-messenger\n sendAndObserveResponses: createDeferredStub(observable)\n }\n }\n // act\n const result = networkFn.call(instanceStub)\n // assert\n subscribe(result, value => {\n t.deepEqual(value, networkDetails)\n })\n t.truthy(instanceStub.rpc.sendAndObserveResponses.calledOnceWith('network'))\n})\n\ntest('should return the accounts as an observable', t => {\n t.plan(2)\n // arrange\n const accountsFn = Index.AppProxy.prototype.accounts\n const observable = of({\n jsonrpc: '2.0',\n id: 'uuid1',\n result: ['accountX', 'accountY', 'accountZ']\n })\n const instanceStub = {\n rpc: {\n // Mimic behaviour of @aragon/rpc-messenger\n sendAndObserveResponses: createDeferredStub(observable)\n }\n }\n // act\n const result = accountsFn.call(instanceStub)\n // assert\n subscribe(result, value => {\n t.deepEqual(value, ['accountX', 'accountY', 'accountZ'])\n })\n t.truthy(instanceStub.rpc.sendAndObserveResponses.calledOnceWith('accounts'))\n})\n\ntest('should send a getApps request for the current app and observe the single response', t => {\n t.plan(3)\n\n const currentApp = {\n appAddress: '0x456',\n appId: 'counterApp',\n appImplementationAddress: '0xcounterApp',\n identifier: 'counter',\n isForwarder: false,\n kernelAddress: '0x123',\n name: 'Counter'\n }\n\n // arrange\n const currentAppFn = Index.AppProxy.prototype.currentApp\n const observable = of({\n jsonrpc: '2.0',\n id: 'uuid1',\n result: currentApp\n })\n const instanceStub = {\n rpc: {\n // Mimic behaviour of @aragon/rpc-messenger\n sendAndObserveResponse: createDeferredStub(observable)\n }\n }\n // act\n const result = currentAppFn.call(instanceStub)\n // assert\n subscribe(result, value => {\n t.is(value.icon(), undefined)\n delete value.icon\n\n t.deepEqual(value, currentApp)\n })\n t.true(instanceStub.rpc.sendAndObserveResponse.calledOnceWith('get_apps'))\n})\n\ntest('should send a getApps request for installed apps and observe the response', t => {\n const initialApps = [{\n appAddress: '0x123',\n appId: 'kernel',\n appImplementationAddress: '0xkernel',\n identifier: undefined,\n isForwarder: false,\n kernelAddress: undefined,\n name: 'Kernel'\n }]\n const endApps = [].concat(initialApps, {\n appAddress: '0x456',\n appId: 'counterApp',\n appImplementationAddress: '0xcounterApp',\n identifier: 'counter',\n isForwarder: false,\n kernelAddress: '0x123',\n name: 'Counter'\n })\n\n // arrange\n const installedAppsFn = Index.AppProxy.prototype.installedApps\n const observable = of(\n {\n jsonrpc: '2.0',\n id: 'uuid1',\n result: initialApps\n }, {\n jsonrpc: '2.0',\n id: 'uuid1',\n result: endApps\n }\n )\n const instanceStub = {\n rpc: {\n // Mimic behaviour of @aragon/rpc-messenger\n sendAndObserveResponses: createDeferredStub(observable)\n }\n }\n // act\n const result = installedAppsFn.call(instanceStub)\n // assert\n let emitIndex = 0\n subscribe(result, value => {\n value.forEach(app => {\n t.is(app.icon(), undefined)\n delete app.icon\n })\n\n if (emitIndex === 0) {\n t.deepEqual(value, initialApps)\n } else if (emitIndex === 1) {\n t.deepEqual(value, endApps)\n } else {\n t.fail('too many emissions')\n }\n\n emitIndex++\n })\n\n t.true(instanceStub.rpc.sendAndObserveResponses.calledOnceWith('get_apps'))\n})\n\ntest('should send an identify request', t => {\n t.plan(1)\n // arrange\n const identifyFn = Index.AppProxy.prototype.identify\n const instanceStub = {\n rpc: {\n send: sinon.stub()\n }\n }\n // act\n identifyFn.call(instanceStub, 'ANT')\n // assert\n t.true(instanceStub.rpc.send.calledOnceWith('identify', ['ANT']))\n})\n\ntest('should send a path request and observe the response', t => {\n t.plan(3)\n // arrange\n const pathFn = Index.AppProxy.prototype.path\n const observable = of(\n {\n jsonrpc: '2.0',\n id: 'uuid1',\n result: 'path1'\n }, {\n jsonrpc: '2.0',\n id: 'uuid1',\n result: 'path2'\n }\n )\n const instanceStub = {\n rpc: {\n // Mimic behaviour of @aragon/rpc-messenger\n sendAndObserveResponses: createDeferredStub(observable)\n }\n }\n // act\n const result = pathFn.call(instanceStub)\n // assert\n let emitIndex = 0\n subscribe(result, value => {\n if (emitIndex === 0) {\n t.deepEqual(value, 'path1')\n } else if (emitIndex === 1) {\n t.deepEqual(value, 'path2')\n } else {\n t.fail('too many emissions')\n }\n\n emitIndex++\n })\n t.true(instanceStub.rpc.sendAndObserveResponses.calledOnceWith('path', ['observe']))\n})\n\ntest('should send a path modification request', t => {\n t.plan(2)\n // arrange\n const path = 'new_path'\n const requestPathFn = Index.AppProxy.prototype.requestPath\n const observable = of({\n jsonrpc: '2.0',\n id: 'uuid1',\n result: null\n })\n const instanceStub = {\n rpc: {\n // Mimic behaviour of @aragon/rpc-messenger\n sendAndObserveResponse: createDeferredStub(observable)\n }\n }\n // act\n const result = requestPathFn.call(instanceStub, path)\n // assert\n subscribe(result, value => t.is(value, null))\n t.true(instanceStub.rpc.sendAndObserveResponse.calledOnceWith('path', ['modify', path]))\n})\n\ntest('should return the events observable', t => {\n t.plan(2)\n // arrange\n const eventsFn = Index.AppProxy.prototype.events\n const observable = of({\n id: 'uuid1',\n result: ['eventA', 'eventB']\n })\n const instanceStub = {\n rpc: {\n // Mimic behaviour of @aragon/rpc-messenger\n sendAndObserveResponses: createDeferredStub(observable)\n }\n }\n // act\n const result = eventsFn.call(instanceStub)\n // assert\n subscribe(result, value => {\n t.deepEqual(value, ['eventA', 'eventB'])\n })\n t.true(instanceStub.rpc.sendAndObserveResponses.calledOnceWith('events', ['allEvents', {}]))\n})\n\ntest('should return an handle for an external contract events', t => {\n t.plan(2)\n const fromBlock = 2\n\n // arrange\n const externalFn = Index.AppProxy.prototype.external\n const observableEvents = of({\n id: 'uuid1',\n result: { name: 'eventA', value: 3000 }\n })\n const jsonInterfaceStub = [\n { type: 'event', name: 'SetPermission' }\n ]\n const instanceStub = {\n rpc: {\n // Mimic behaviour of @aragon/rpc-messenger\n sendAndObserveResponses: createDeferredStub(observableEvents)\n }\n }\n // act\n const result = externalFn.call(instanceStub, '0xextContract', jsonInterfaceStub)\n // events from starting block\n const eventsObservable = result.events({ fromBlock })\n // assert\n subscribe(eventsObservable, value => {\n t.deepEqual(value, { name: 'eventA', value: 3000 })\n })\n t.true(\n instanceStub.rpc.sendAndObserveResponses.calledOnceWith(\n 'external_events',\n ['0xextContract', [jsonInterfaceStub[0]], 'allEvents', { fromBlock }]\n )\n )\n})\n\ntest('should return a handle for creating external calls', t => {\n t.plan(2)\n // arrange\n const externalFn = Index.AppProxy.prototype.external\n const observableCall = of({\n id: 'uuid4',\n result: 'bob was granted permission for the counter app'\n })\n\n const jsonInterfaceStub = [\n { type: 'function', name: 'grantPermission', constant: true }\n ]\n\n const instanceStub = {\n rpc: {\n // Mimic behaviour of @aragon/rpc-messenger\n sendAndObserveResponse: createDeferredStub(observableCall)\n }\n }\n\n // act\n const result = externalFn.call(instanceStub, '0xextContract', jsonInterfaceStub)\n const callResult = result.grantPermission('0xbob', '0xcounter')\n\n // assert\n subscribe(callResult, value => {\n t.is(value, 'bob was granted permission for the counter app')\n })\n\n t.true(\n instanceStub.rpc.sendAndObserveResponse.calledOnceWith(\n 'external_call',\n ['0xextContract', jsonInterfaceStub[0], '0xbob', '0xcounter']\n )\n )\n})\n\ntest('should return a handle for creating external transaction intents', t => {\n t.plan(2)\n // arrange\n const externalFn = Index.AppProxy.prototype.external\n const observableIntent = of({\n id: 'uuid4',\n result: 10\n })\n\n const jsonInterfaceStub = [\n { type: 'function', name: 'add', constant: false }\n ]\n\n const instanceStub = {\n rpc: {\n // Mimic behaviour of @aragon/rpc-messenger\n sendAndObserveResponse: createDeferredStub(observableIntent)\n }\n }\n\n // act\n const result = externalFn.call(instanceStub, '0xextContract', jsonInterfaceStub)\n const intentResult = result.add(10)\n\n // assert\n subscribe(intentResult, value => {\n t.is(value, 10)\n })\n t.true(\n instanceStub.rpc.sendAndObserveResponse.calledOnceWith(\n 'external_intent',\n ['0xextContract', jsonInterfaceStub[0], 10]\n )\n )\n})\n\ntest('should return the state from cache', t => {\n t.plan(3)\n // arrange\n const stateFn = Index.AppProxy.prototype.state\n const stateObservable = new Subject()\n const instanceStub = {\n rpc: {\n // Mimic behaviour of @aragon/rpc-messenger\n sendAndObserveResponses: createDeferredStub(stateObservable)\n }\n }\n // act\n const result = stateFn.call(instanceStub)\n // assert\n t.true(instanceStub.rpc.sendAndObserveResponses.calledOnceWith('cache', ['observe', 'state']))\n\n let counter = 0\n subscribe(result, value => {\n if (counter === 0) {\n t.deepEqual(value, { counter: 5 })\n } else if (counter === 1) {\n t.deepEqual(value, { counter: 6 })\n }\n counter++\n })\n // send state events\n stateObservable.next({\n id: 'uuid1',\n result: { counter: 5 }\n })\n stateObservable.next({\n id: 'uuid1',\n result: { counter: 6 }\n })\n})\n\ntest('should create a store and reduce correctly without previously cached state', async t => {\n t.plan(2)\n // arrange\n const storeFn = Index.AppProxy.prototype.store\n const observableEvents = new Subject()\n\n const instanceStub = {\n accounts: () => from([\n ['0x0000000000000000000000000000000000000abc']\n ]),\n cache: () => of(),\n events: createDeferredStub(observableEvents),\n getCache: () => from([null]),\n pastEvents: () => of([]),\n web3Eth: sinon.stub().withArgs('getBlockNumber').returns(from(['4385398']))\n }\n const reducer = (state, action) => {\n if (state === null) state = { actionHistory: [], counter: 0 }\n\n switch (action.event) {\n case 'Add':\n state.actionHistory.push(action)\n state.counter += action.payload\n return state\n case 'Subtract':\n state.actionHistory.push(action)\n state.counter -= action.payload\n return state\n }\n return state\n }\n // act\n const result = storeFn.call(instanceStub, reducer)\n // assert\n subscribe(result, value => {\n if (value.counter === 2) {\n t.deepEqual(value.actionHistory, [\n { event: 'Add', payload: 2 }\n ])\n }\n if (value.counter === 12) {\n t.deepEqual(value.actionHistory, [\n { event: 'Add', payload: 2 },\n { event: 'Add', payload: 10 }\n ])\n }\n })\n // send events; wait to avoid grouping through debounce\n await sleep(250)\n observableEvents.next({ event: 'Add', payload: 2 })\n await sleep(500)\n observableEvents.next({ event: 'Add', payload: 10 })\n await sleep(1000)\n})\n\ntest('should create a store and reduce correctly with previously cached state', async t => {\n t.plan(2)\n // arrange\n const storeFn = Index.AppProxy.prototype.store\n const observableEvents = new Subject()\n\n const instanceStub = {\n accounts: () => from([\n ['0x0000000000000000000000000000000000000abc']\n ]),\n cache: () => of(),\n events: createDeferredStub(observableEvents),\n getCache: () => of({\n state: {\n actionHistory: [\n { event: 'Add', payload: 5 }\n ],\n counter: 5\n },\n blockNumber: 1\n }),\n pastEvents: () => of([]),\n web3Eth: sinon.stub().withArgs('getBlockNumber').returns(from(['4385398']))\n }\n const reducer = (state, action) => {\n if (state === null) state = { actionHistory: [], counter: 0 }\n\n switch (action.event) {\n case 'Add':\n state.actionHistory.push(action)\n state.counter += action.payload\n return state\n case 'Subtract':\n state.actionHistory.push(action)\n state.counter -= action.payload\n return state\n }\n return state\n }\n // act\n const result = storeFn.call(instanceStub, reducer)\n // assert\n subscribe(result, value => {\n if (value.counter === 5) {\n t.deepEqual(value.actionHistory, [\n { event: 'Add', payload: 5 }\n ])\n }\n if (value.counter === 7) {\n t.deepEqual(value.actionHistory, [\n { event: 'Add', payload: 5 },\n { event: 'Add', payload: 2 }\n ])\n }\n if (value.counter === 17) {\n t.deepEqual(value.actionHistory, [\n { event: 'Add', payload: 5 },\n { event: 'Add', payload: 2 },\n { event: 'Add', payload: 10 }\n ])\n }\n })\n // send events; wait to avoid grouping through debounce\n await sleep(250)\n observableEvents.next({ event: 'Add', payload: 2 })\n await sleep(500)\n observableEvents.next({ event: 'Add', payload: 10 })\n await sleep(500)\n})\n\ntest('should perform a call to the contract and observe the response', t => {\n t.plan(2)\n // arrange\n const callFn = Index.AppProxy.prototype.call\n const observable = of({\n id: 'uuid1',\n result: 'success'\n })\n const instanceStub = {\n rpc: {\n // Mimic behaviour of @aragon/rpc-messenger\n sendAndObserveResponse: createDeferredStub(observable)\n }\n }\n // act\n const result = callFn.call(instanceStub, 'transferEth', 10)\n // assert\n subscribe(result, value => {\n t.deepEqual(value, 'success')\n })\n t.true(instanceStub.rpc.sendAndObserveResponse.calledOnceWith('call', ['transferEth', 10]))\n})\n\ntest('should send a describeScript request and observe the response', t => {\n t.plan(2)\n // arrange\n const describeScriptFn = Index.AppProxy.prototype.describeScript\n const observable = of({\n id: 'uuid1',\n result: 'script executed'\n })\n const instanceStub = {\n rpc: {\n // Mimic behaviour of @aragon/rpc-messenger\n sendAndObserveResponse: createDeferredStub(observable)\n }\n }\n // act\n const result = describeScriptFn.call(instanceStub, 'goto fail')\n // assert\n subscribe(result, value => {\n t.deepEqual(value, 'script executed')\n })\n t.true(instanceStub.rpc.sendAndObserveResponse.calledOnceWith('describe_script', ['goto fail']))\n})\n\ntest('should send a web3Eth function request and observe the response', t => {\n t.plan(2)\n // arrange\n const web3EthFn = Index.AppProxy.prototype.web3Eth\n const observable = of({\n id: 'uuid1',\n result: ['accountA', 'accountB']\n })\n const instanceStub = {\n rpc: {\n // Mimic behaviour of @aragon/rpc-messenger\n sendAndObserveResponse: createDeferredStub(observable)\n }\n }\n // act\n const result = web3EthFn.call(instanceStub, 'getAccounts', 5)\n // assert\n subscribe(result, value => {\n t.deepEqual(value, ['accountA', 'accountB'])\n })\n t.true(instanceStub.rpc.sendAndObserveResponse.calledOnceWith('web3_eth', ['getAccounts', 5]))\n})\n\ntest('should return the registerAppMetadata observable', t => {\n t.plan(3)\n // arrange\n const registerAppMetadataFn = Index.AppProxy.prototype.registerAppMetadata\n const instanceStub = {\n rpc: {\n send: sinon.stub()\n }\n }\n // act\n registerAppMetadataFn.call(instanceStub, '1', 'uuid1', 'QmrandomhashoceBBSBGmYiHVFQLHN8Uex6CeqExmp6Ggk', ['0xcafe'])\n // assert\n t.is(instanceStub.rpc.send.getCall(0).args[0], 'register_app_metadata')\n t.deepEqual(instanceStub.rpc.send.getCall(0).args[1], ['1', 'uuid1', 'QmrandomhashoceBBSBGmYiHVFQLHN8Uex6CeqExmp6Ggk', ['0xcafe']])\n // act and assert default 'to'\n registerAppMetadataFn.call(instanceStub, '1', 'uuid2', 'QmrandomhashoceBBSBGmYiHVFQLHN8Uex6CeqExmp6GgK')\n t.deepEqual(instanceStub.rpc.send.getCall(1).args[1], ['1', 'uuid2', 'QmrandomhashoceBBSBGmYiHVFQLHN8Uex6CeqExmp6GgK', ['*']])\n})\n\ntest('should return individual metadata entry', t => {\n t.plan(3)\n\n // arrange\n const queryAppMetadataFn = Index.AppProxy.prototype.queryAppMetadata\n\n const observable = of({\n id: 'uuid1',\n result: {\n from: '0xfed',\n to: [ '0xcafe', '0xdeaddead' ],\n dataId: 'u2',\n cid: 'Qmrandomhash'\n } })\n\n const instanceStub = {\n rpc: {\n sendAndObserveResponse: createDeferredStub(observable)\n }\n }\n\n // act\n const result = queryAppMetadataFn.call(instanceStub, 'a', '1')\n\n // assert\n t.is(instanceStub.rpc.sendAndObserveResponse.getCall(0).args[0], 'query_app_metadata')\n t.deepEqual(instanceStub.rpc.sendAndObserveResponse.getCall(0).args[1], ['a', '1'])\n\n result.subscribe(value => {\n t.deepEqual(value, {\n from: '0xfed',\n to: [ '0xcafe', '0xdeaddead' ],\n dataId: 'u2',\n cid: 'Qmrandomhash'\n })\n })\n})\n\ntest('should return appMetadata observable', t => {\n t.plan(3)\n\n // arrange\n const getAppMetadataFn = Index.AppProxy.prototype.getAppMetadata\n\n const observable = from([{\n event: 'AppMetadata',\n result: {\n from: '0xfed',\n to: [ '0xcafe', '0xdeaddead' ],\n dataId: 'u2',\n cid: 'Qmrandomhash'\n }\n }])\n const instanceStub = {\n rpc: {\n sendAndObserveResponses: sinon.stub().returns(observable)\n }\n }\n // act\n const result = getAppMetadataFn.call(instanceStub)\n // assert\n t.truthy(instanceStub.rpc.sendAndObserveResponses.getCall(0))\n\n result.subscribe(value => {\n t.deepEqual(value, {\n from: '0xfed',\n to: [ '0xcafe', '0xdeaddead' ],\n dataId: 'u2',\n cid: 'Qmrandomhash'\n })\n })\n\n t.is(instanceStub.rpc.sendAndObserveResponses.getCall(0).args[0], 'get_app_metadata')\n})\ntest('should submit a new action', t => {\n t.plan(2)\n // arrange\n const newActionFn = Index.AppProxy.prototype.newForwardedAction\n const instanceStub = {\n rpc: {\n send: sinon.stub()\n }\n }\n // act\n newActionFn.call(instanceStub, '0', '49', 'testScript')\n // assert\n t.is(instanceStub.rpc.send.getCall(0).args[0], 'update_forwarded_action')\n t.deepEqual(instanceStub.rpc.send.getCall(0).args[1], ['0', '49', 'testScript'])\n})\n\ntest('should update an action', t => {\n t.plan(4)\n // arrange\n const updateActionFn = Index.AppProxy.prototype.updateForwardedAction\n const instanceStub = {\n rpc: {\n send: sinon.stub()\n }\n }\n const instanceStub2 = {\n rpc: {\n send: sinon.stub()\n }\n }\n // act\n updateActionFn.call(instanceStub, '1', '49', 'testScript', '0')\n // assert\n t.is(instanceStub.rpc.send.getCall(0).args[0], 'update_forwarded_action')\n t.deepEqual(instanceStub.rpc.send.getCall(0).args[1], ['1', '49', 'testScript', '0'])\n\n // act\n updateActionFn.call(instanceStub2, '2', '49', 'updatedScript', '1')\n // assert\n t.is(instanceStub2.rpc.send.getCall(0).args[0], 'update_forwarded_action')\n t.deepEqual(instanceStub2.rpc.send.getCall(0).args[1], ['2', '49', 'updatedScript', '1'])\n})\n\ntest('should return the forwardedActions observable', t => {\n t.plan(3)\n // arrange\n const getFwdActionsFn = Index.AppProxy.prototype.getForwardedActions\n const observable = of({\n event: 'uuid1',\n result: {\n event: 'ForwardedActions',\n returnValues: ['forwardedAction1', 'forwardedAction2']\n }\n })\n const instanceStub = {\n rpc: {\n sendAndObserveResponses: sinon.stub()\n .returns(observable)\n }\n }\n // act\n const result = getFwdActionsFn.call(instanceStub)\n // assert\n // the call to sendAndObserveResponse should not be defered until we subscribe,\n // since we are working with a BehaviorSubject and just want the latest and greatest\n t.truthy(instanceStub.rpc.sendAndObserveResponses.getCall(0))\n result.subscribe(value => {\n t.deepEqual(value, {\n event: 'ForwardedActions',\n returnValues: ['forwardedAction1', 'forwardedAction2']\n })\n })\n t.is(instanceStub.rpc.sendAndObserveResponses.getCall(0).args[0], 'get_forwarded_actions')\n})\n\ntest('should send a trigger request to the wrapper', t => {\n t.plan(2)\n // arrange\n const triggerFn = Index.AppProxy.prototype.trigger\n const instanceStub = {\n rpc: {\n send: sinon.stub()\n }\n }\n // act\n triggerFn.call(instanceStub, 'TriggerTest', { testprop: '123abc' })\n // assert\n t.is(instanceStub.rpc.send.getCall(0).args[0], 'trigger')\n t.deepEqual(instanceStub.rpc.send.getCall(0).args[1], ['TriggerTest', { testprop: '123abc' }])\n})\n"],"file":"index.test.js"}