-
-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: improve sim tests for some remaining feedback (#6654)
* Restructure web3.js plugin * Verify the blobs * Fix plugin cache * Compare blobs as buffer not as strings * Fix the blobs assertion
- Loading branch information
1 parent
669239b
commit ae984f0
Showing
7 changed files
with
107 additions
and
70 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import {Web3} from "web3"; | ||
import {Web3AdminPlugin} from "./web3AdminPlugin.js"; | ||
import {Web3ExtendedEthPlugin} from "./web3ExtendedEthPlugin.js"; | ||
|
||
export function registerWeb3JsPlugins(web3: Web3): void { | ||
web3.registerPlugin(new Web3AdminPlugin()); | ||
web3.registerPlugin(new Web3ExtendedEthPlugin()); | ||
} |
43 changes: 43 additions & 0 deletions
43
packages/cli/test/utils/simulation/web3js/plugins/web3AdminPlugin.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,43 @@ | ||
import {Web3PluginBase} from "web3"; | ||
|
||
export class Web3AdminPlugin extends Web3PluginBase { | ||
/** | ||
* The admin plugin as available via the provider object | ||
* like in the example below. | ||
* | ||
* await node.web3.admin.addPeer(elIdentity.enode); | ||
*/ | ||
pluginNamespace = "admin"; | ||
|
||
async nodeInfo(): Promise<{ | ||
enode: string; | ||
id: string; | ||
ip: string; | ||
listenAddr: string; | ||
name: string; | ||
ports: { | ||
discovery: number; | ||
listener: number; | ||
}; | ||
protocols: { | ||
eth: { | ||
difficulty: number; | ||
genesis: string; | ||
head: string; | ||
network: number; | ||
}; | ||
}; | ||
}> { | ||
return this.requestManager.send({method: "admin_nodeInfo", params: []}); | ||
} | ||
|
||
async addPeer(enode: string): Promise<boolean> { | ||
return this.requestManager.send({method: "admin_addPeer", params: [enode]}); | ||
} | ||
} | ||
|
||
declare module "web3" { | ||
interface Web3Context { | ||
admin: Web3AdminPlugin; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
packages/cli/test/utils/simulation/web3js/plugins/web3ExtendedEthPlugin.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,19 @@ | ||
import {Web3PluginBase} from "web3"; | ||
|
||
export class Web3ExtendedEthPlugin extends Web3PluginBase { | ||
pluginNamespace = "extended"; | ||
|
||
async sendRawTransaction(tx: string): Promise<string> { | ||
return this.requestManager.send({method: "eth_sendRawTransaction", params: [tx]}); | ||
} | ||
|
||
async sendPlainTransaction(...params: unknown[]): Promise<string> { | ||
return this.requestManager.send({method: "eth_sendTransaction", params: [...params]}); | ||
} | ||
} | ||
|
||
declare module "web3" { | ||
interface Web3Context { | ||
extended: Web3ExtendedEthPlugin; | ||
} | ||
} |
ae984f0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible performance regression was detected for some benchmarks.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold.
Full benchmark results