Skip to content

Commit

Permalink
fix e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
KaoImin committed Aug 30, 2023
1 parent 02d4e51 commit 7ad4beb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
39 changes: 20 additions & 19 deletions tests/e2e/src/create_test_data/createTestDataManage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import erc20 from "./ERC20.json";
const basePath = "./src/test_data_temp_file";
const option = { timeout: 1000 * 30 };
const web3 = new Web3(
new Web3.providers.HttpProvider(Config.getIns().axonRpc.url, option)
new Web3.providers.HttpProvider(Config.getIns().axonRpc.url, option),
);
const accountFrom = web3.eth.accounts.privateKeyToAccount(
Config.getIns().hexPrivateKey
Config.getIns().hexPrivateKey,
);
const transactionInfo = {
contractAddress: "",
Expand All @@ -27,6 +27,7 @@ const filterIds = {
filter_id_2: "",
filter_id_3: "",
};
const hexPrefix = "0x";
const createTestDataMange = {
async savejson(filePath, data) {
const dataStr = JSON.stringify(data, null, 4);
Expand Down Expand Up @@ -66,10 +67,8 @@ const createTestDataMange = {
transactionInfo.transactionIndex = receipt.transactionIndex;
transactionInfo.accountAddress = accountFrom.address;
transactionInfo.hexBlockNumber = `0x${receipt.blockNumber.toString(16)}`;
transactionInfo.topic1 =
"0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0";
transactionInfo.topic2 =
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef";
transactionInfo.topic1 = "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0";
transactionInfo.topic2 = "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef";
await this.savejson(`${basePath}/testData_1.json`, transactionInfo);
},
async writeFilterIds(filterIdIndex, id) {
Expand Down Expand Up @@ -115,6 +114,7 @@ const createTestDataMange = {
fs.mkdirSync(`${basePath}/`);
}
},

async sendRawTestTx() {
const toAddress = Config.getIns().acount2;
const nonce = (await web3.eth.getTransactionCount(accountFrom.address)) + 1;
Expand All @@ -126,17 +126,18 @@ const createTestDataMange = {
value: web3.utils.toHex(web3.utils.toWei("1", "ether")),
};
// eslint-disable-next-line global-require
const { Common } = require('@ethereumjs/common');
const {Transaction} = require('@ethereumjs/tx');
const common = Common.custom({ chainId: web3.utils.toHex(Config.getIns().axonRpc.chainId)});
const tx = Transaction.fromTxData(txObject, {common});
const privateKey = Buffer.from(Config.getIns().hexPrivateKey.substring(2), 'hex');
const { Common } = require("@ethereumjs/common");
const { Transaction } = require("@ethereumjs/tx");
const common = Common.custom({ chainId: web3.utils.toHex(Config.getIns().axonRpc.chainId) });
const tx = Transaction.fromTxData(txObject, { common });
const privateKey = Buffer.from(Config.getIns().hexPrivateKey.substring(2), "hex");
const signedTx = tx.sign(privateKey);
const serializedTx = signedTx.serialize();
return serializedTx.toString("hex");
return hexPrefix + serializedTx.toString("hex");
},

async sendPreEip155RawTestTx() {
const toAddress = Config.getIns().acount2;
const toAddress = Config.getIns().aount2;
const nonce = (await web3.eth.getTransactionCount(accountFrom.address)) + 1;
const txObject = {
nonce: web3.utils.toHex(nonce),
Expand All @@ -146,14 +147,14 @@ const createTestDataMange = {
value: web3.utils.toHex(web3.utils.toWei("1", "ether")),
};
// eslint-disable-next-line global-require
const { Chain, Common, Hardfork } = require('@ethereumjs/common');
const {Transaction} = require('@ethereumjs/tx');
const common = new Common({chain: Chain.Mainnet, hardfork: Hardfork.TangerineWhistle});
const tx = Transaction.fromTxData(txObject,{common});
const privateKey = Buffer.from(Config.getIns().hexPrivateKey.substring(2), 'hex');
const { Chain, Common, Hardfork } = require("@ethereumjs/common");
const { Transaction } = require("@ethereumjs/tx");
const common = new Common({ chain: Chain.Mainnet, hardfork: Hardfork.TangerineWhistle });
const tx = Transaction.fromTxData(txObject, { common });
const privateKey = Buffer.from(Config.getIns().hexPrivateKey.substring(2), "hex");
const signedTx = tx.sign(privateKey);
const serializedTx = signedTx.serialize();
return serializedTx.toString("hex");
return hexPrefix + serializedTx.toString("hex");
},
};
export default createTestDataMange;
6 changes: 3 additions & 3 deletions tests/e2e/src/web3_sha3.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe("web3_sha3", () => {
const param1 = await page.$(goto.pageIds.param1Id);
await testType.type("1"); // 0: none params 1: common params to request 2: more params
await param1.type("");
await goto.check(page, "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470");
await goto.check(page, "-32603");
});

/**
Expand Down Expand Up @@ -56,7 +56,7 @@ describe("web3_sha3", () => {
await testType.type("1");
const param1 = await page.$(goto.pageIds.param1Id);
await param1.type("123456");
await goto.check(page, "0x6adf031833174bbe4c85eafe59ddb54e6584648c2c962c6f94791ab49caa0ad4");
await goto.check(page, "-32603");
});

/**
Expand All @@ -67,7 +67,7 @@ describe("web3_sha3", () => {
await testType.type("1");
const param1 = await page.$(goto.pageIds.param1Id);
await param1.type("68656c6c6f20776f726c64");
await goto.check(page, "0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad");
await goto.check(page, "-32603");
});

/**
Expand Down

0 comments on commit 7ad4beb

Please sign in to comment.