From 7a06e2cb429cc9f4cfefeffe7345f2691822484c Mon Sep 17 00:00:00 2001 From: yann300 Date: Sun, 16 Jun 2024 22:56:10 +0200 Subject: [PATCH] fix test --- libs/remix-simulator/src/provider.ts | 11 ++++++++--- libs/remix-simulator/test/accounts.ts | 11 ++++------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/libs/remix-simulator/src/provider.ts b/libs/remix-simulator/src/provider.ts index 3e56a2e4e7..de7573e5ba 100644 --- a/libs/remix-simulator/src/provider.ts +++ b/libs/remix-simulator/src/provider.ts @@ -108,11 +108,11 @@ export class Provider { callback(new Error('unknown method ' + payload.method)) } - sendAsync (payload: JSONRPCRequestPayload, callback: (err: Error, result?: JSONRPCResponsePayload) => void) { + async sendAsync (payload: JSONRPCRequestPayload, callback?: (err: Error, result?: JSONRPCResponsePayload) => void) : Promise { return new Promise((resolve,reject)=>{ const cb = (err, result) => { if (typeof callback==='function'){ - callback(err,result) + return callback(err, result) } if (err){ return reject(err) @@ -124,9 +124,14 @@ export class Provider { } send (payload, callback) { - return this.sendAsync(payload,callback) + return this.sendAsync(payload, callback) } + async request (payload: JSONRPCRequestPayload) : Promise { + const ret = await this.sendAsync(payload) + return ret.result + } + isConnected () { return true } diff --git a/libs/remix-simulator/test/accounts.ts b/libs/remix-simulator/test/accounts.ts index ed7c1c916d..17635383fc 100644 --- a/libs/remix-simulator/test/accounts.ts +++ b/libs/remix-simulator/test/accounts.ts @@ -52,7 +52,7 @@ describe('Accounts', () => { }, message: { prompt: "Welcome! In order to authenticate to this website, sign this request and your public address will be sent to the server in a verifiable way.", - createdAt: `${Date.now()}`, + createdAt: 1718570375196, }, primaryType: 'AuthRequest', types: { @@ -68,14 +68,11 @@ describe('Accounts', () => { ], }, }; - const result = await web3.currentProvider.sendAsync({ + const result = await web3.currentProvider.request({ method: 'eth_signTypedData', - params: [accounts[0], typedData], - id: 0, - jsonrpc: '2.0' + params: [accounts[0], typedData] }) - console.log(result) - assert.equal(result, '0xe4ee76332af49888d86a09eea70dfd5b9a7085e2e013cbba4c0cb41766eab69a6216f18b80d9277241ce35b74b6c46add36d5189eb5a94a258f076dfc4dd21161b') + assert.equal(result, '0x248d23de0e23231370db8aa21ad5908ca90c33ae2b8c611b906674bda6b1a8b85813f945c2ea896316e240089029619ab3d801a1b098c199bd462dd8026349da1c') }) }) })