generated from web3/web3.js-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
262 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/web3-plugin-wallet-rpc/test/wallet_getPermissions.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Web3 } from "web3"; | ||
|
||
import { WalletRpcPlugin } from "../src"; | ||
|
||
describe("WalletRpcPlugin", () => { | ||
describe("wallet_getPermissions", () => { | ||
const web3 = new Web3("http://127.0.0.1:8545"); | ||
web3.registerPlugin(new WalletRpcPlugin()); | ||
|
||
const requestManagerSendSpy = jest.fn(); | ||
web3.requestManager.send = requestManagerSendSpy; | ||
|
||
afterEach(() => { | ||
requestManagerSendSpy.mockClear(); | ||
}); | ||
|
||
it("should call the method with expected params", async () => { | ||
await web3.walletRpc.getPermissions(); | ||
|
||
expect(requestManagerSendSpy).toHaveBeenCalledWith({ | ||
method: "wallet_getPermissions", | ||
params: [], | ||
}); | ||
}); | ||
}); | ||
}); |
30 changes: 30 additions & 0 deletions
30
packages/web3-plugin-wallet-rpc/test/wallet_requestPermissions.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Web3 } from "web3"; | ||
|
||
import { WalletRpcPlugin } from "../src"; | ||
|
||
describe("WalletRpcPlugin", () => { | ||
describe("wallet_requestPermissions", () => { | ||
const web3 = new Web3("http://127.0.0.1:8545"); | ||
web3.registerPlugin(new WalletRpcPlugin()); | ||
|
||
const requestManagerSendSpy = jest.fn(); | ||
web3.requestManager.send = requestManagerSendSpy; | ||
|
||
afterEach(() => { | ||
requestManagerSendSpy.mockClear(); | ||
}); | ||
|
||
it("should call the method with expected params", async () => { | ||
const request = { | ||
eth_accounts: {}, | ||
}; | ||
|
||
await web3.walletRpc.requestPermissions(request); | ||
|
||
expect(requestManagerSendSpy).toHaveBeenCalledWith({ | ||
method: "wallet_requestPermissions", | ||
params: [request], | ||
}); | ||
}); | ||
}); | ||
}); |
30 changes: 30 additions & 0 deletions
30
packages/web3-plugin-wallet-rpc/test/wallet_revokePermissions.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Web3 } from "web3"; | ||
|
||
import { WalletRpcPlugin } from "../src"; | ||
|
||
describe("WalletRpcPlugin", () => { | ||
describe("wallet_revokePermissions", () => { | ||
const web3 = new Web3("http://127.0.0.1:8545"); | ||
web3.registerPlugin(new WalletRpcPlugin()); | ||
|
||
const requestManagerSendSpy = jest.fn(); | ||
web3.requestManager.send = requestManagerSendSpy; | ||
|
||
afterEach(() => { | ||
requestManagerSendSpy.mockClear(); | ||
}); | ||
|
||
it("should call the method with expected params", async () => { | ||
const request = { | ||
eth_accounts: {}, | ||
}; | ||
|
||
await web3.walletRpc.revokePermissions(request); | ||
|
||
expect(requestManagerSendSpy).toHaveBeenCalledWith({ | ||
method: "wallet_revokePermissions", | ||
params: [request], | ||
}); | ||
}); | ||
}); | ||
}); |