From d2a0af9c9eb029e9b6f94007c40ee7ab026427aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20D=C3=ADaz?= Date: Fri, 4 Oct 2024 11:54:06 +0200 Subject: [PATCH] test(registry): WitOracleRadonRegistry.verifyRadonRetriteval(bytes32,string) --- test/witOracleRadonRegistry.spec.js | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/test/witOracleRadonRegistry.spec.js b/test/witOracleRadonRegistry.spec.js index cb4fc8f9..4b59e74e 100644 --- a/test/witOracleRadonRegistry.spec.js +++ b/test/witOracleRadonRegistry.spec.js @@ -96,8 +96,8 @@ contract("WitOracleRadonRegistry", (accounts) => { let rngSourceHash let binanceTickerHash + let binanceUsdTickerHash let uniswapToken1PriceHash - let heavyRetrievalHash let rngHash @@ -130,7 +130,7 @@ contract("WitOracleRadonRegistry", (accounts) => { assert.equal(tx.logs.length, 0, "some unexpected event was emitted") }) it("generates proper hash upon offchain verification of already existing randmoness source", async () => { - const hash = await radonRegistry.verifyRadonRetrieval.call( + const hash = await radonRegistry.methods["verifyRadonRetrieval(uint8,string,string,string[2][],bytes)"].call( 2, // requestMethod "", // requestURL "", // requestBody @@ -185,6 +185,27 @@ contract("WitOracleRadonRegistry", (accounts) => { "NewRadonRetrieval" ) }) + it("fork existing retrieval by settling one out of two parameters", async () => { + const tx = await radonRegistry.verifyRadonRetrieval( + binanceTickerHash, + "USD" + ) + assert.equal(tx.logs.length, 1) + expectEvent( + tx.receipt, + "NewRadonRetrieval" + ) + binanceUsdTickerHash = tx.logs[0].args.hash + }) + it("metadata of forked retrieval gets stored as expected", async () => { + const ds = await radonRegistry.lookupRadonRetrieval.call(binanceUsdTickerHash) + assert.equal(ds.method, 1) // HTTP-GET + assert.equal(ds.dataType, 4) // Integer + assert.equal(ds.url, "https://api.binance.us/api/v3/ticker/price?symbol=\\0\\USD") + assert.equal(ds.body, "") + assert(ds.headers.length === 0) + assert.equal(ds.radonScript, "0x841877821864696c61737450726963658218571a000f4240185b") + }) }) context("Witnet.RadonRetrievalMethods.HttpPost", async () => { it(