Skip to content

Commit

Permalink
Fix BuiltInNoSecurity option. Fix unit tests. Fix e2e tests. Add test…
Browse files Browse the repository at this point in the history
… for hardhat_impersonateAccount
  • Loading branch information
MexicanAce committed Dec 13, 2023
1 parent 952f4e4 commit 2783423
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
7 changes: 3 additions & 4 deletions e2e-tests/test/hardhat-apis.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ describe("hardhat_mine", function () {
});
});

// TODO: Run this test once eth_sendTransaction has been implemented or when different tests have been added
xdescribe("hardhat_impersonateAccount & hardhat_stopImpersonatingAccount", function () {
describe("hardhat_impersonateAccount & hardhat_stopImpersonatingAccount", function () {
it("Should allow transfers of funds without knowing the Private Key", async function () {
// Arrange
const userWallet = Wallet.createRandom().connect(provider);
Expand All @@ -84,8 +83,8 @@ xdescribe("hardhat_impersonateAccount & hardhat_stopImpersonatingAccount", funct
await recieptTx.wait();

// Assert
expect(await userWallet.getBalance()).to.equal(ethers.utils.parseEther("0.42"));
expect(await provider.getBalance(RichAccounts[0].Account)).to.equal(beforeBalance.sub(0.42));
expect((await userWallet.getBalance()).eq(ethers.utils.parseEther("0.42"))).to.true;
expect((await provider.getBalance(RichAccounts[0].Account)).eq(beforeBalance.sub(ethers.utils.parseEther("0.42")))).to.true;
});
});

Expand Down
4 changes: 2 additions & 2 deletions e2e-tests/test/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe("Greeter Smart Contract", function () {

// Validate log is created
expect(receipt.logs.length).to.greaterThanOrEqual(1);
const setGreetingLog = receipt.logs[1];
const setGreetingLog = receipt.logs[0];
expect(setGreetingLog.address).to.equal(greeter.address);

const eventInterface = new ethers.utils.Interface(["event LogString(string value)"]);
Expand All @@ -79,7 +79,7 @@ describe("Greeter Smart Contract", function () {
let receipt: TransactionReceipt = await setGreetingTx.wait();

// Create filter
const topic = receipt.logs[1].topics[0];
const topic = receipt.logs[0].topics[0];
const filterId = await provider.send("eth_newFilter", [
{
fromBlock: "earliest",
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/test/zks-apis.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe("zks_estimateFee", function () {
const response: Fee = await provider.send("zks_estimateFee", [transaction]);

// Assert
expect(ethers.BigNumber.from(response.gas_limit)).to.eql(ethers.BigNumber.from("732250"), "Unexpected gas_limit");
expect(ethers.BigNumber.from(response.gas_limit)).to.eql(ethers.BigNumber.from("621166"), "Unexpected gas_limit");
expect(ethers.BigNumber.from(response.gas_per_pubdata_limit)).to.eql(
ethers.BigNumber.from("4080"),
"Unexpected gas_per_pubdata_limit"
Expand Down
6 changes: 4 additions & 2 deletions src/node/in_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1722,7 +1722,9 @@ mod tests {
use zksync_types::utils::deployed_address_create;

use super::*;
use crate::{http_fork_source::HttpForkSource, node::InMemoryNode, testing};
use crate::{
http_fork_source::HttpForkSource, node::InMemoryNode, system_contracts::Options, testing,
};

#[tokio::test]
async fn test_run_l2_tx_validates_tx_gas_limit_too_high() {
Expand Down Expand Up @@ -1842,7 +1844,7 @@ mod tests {
None,
None,
InMemoryNodeConfig {
system_contracts_options: Option::BuiltInWithoutSecurity,
system_contracts_options: Options::BuiltInWithoutSecurity,
..Default::default()
},
);
Expand Down
4 changes: 1 addition & 3 deletions src/system_contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,9 @@ fn bsc_load_with_bootloader(
include_bytes!("deps/contracts/DefaultAccount.json"),
),
Options::Local => read_sys_contract_bytecode("", "DefaultAccount", ContractLanguage::Sol),
// TODO: restore
Options::BuiltInWithoutSecurity => bytecode_from_slice(
"DefaultAccountNoSecurity",
// include_bytes!("deps/contracts/DefaultAccountNoSecurity.json"),
include_bytes!("deps/contracts/DefaultAccount.json"),
include_bytes!("deps/contracts/DefaultAccountNoSecurity.json"),
),
};

Expand Down

0 comments on commit 2783423

Please sign in to comment.