Skip to content

Commit

Permalink
fix(connector-besu): remove magic strings
Browse files Browse the repository at this point in the history
Fixes hyperledger#1104

Signed-off-by: Hana Awad <awadhana0825@gmail.com>
  • Loading branch information
awadhana committed Jul 3, 2021
1 parent 0ca0769 commit 5811935
Show file tree
Hide file tree
Showing 23 changed files with 185 additions and 124 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ test("can get past logs of an account", async (t: Test) => {
*
* @see https://github.com/hyperledger/besu/blob/1.5.1/config/src/main/resources/dev.json
*/
const firstHighNetWorthAccount = "627306090abaB3A6e1400e9345bC60c78a8BEf57";

const firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();

const web3 = new Web3(rpcApiHttpHost);
const testEthAccount = web3.eth.accounts.create(uuidv4());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ test(testCase, async (t: Test) => {
*
* @see https://github.com/hyperledger/besu/blob/1.5.1/config/src/main/resources/dev.json
*/
const firstHighNetWorthAccount = "627306090abaB3A6e1400e9345bC60c78a8BEf57";

const firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();
const besuKeyPair = {
privateKey:
"c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3",
privateKey: besuTestLedger.getGenesisAccountPrivKey(),
};

const web3 = new Web3(rpcApiHttpHost);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test("can get balance of an account", async (t: Test) => {
*
* @see https://github.com/hyperledger/besu/blob/1.5.1/config/src/main/resources/dev.json
*/
const firstHighNetWorthAccount = "627306090abaB3A6e1400e9345bC60c78a8BEf57";
const firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();
const web3 = new Web3(rpcApiHttpHost);
const testEthAccount = web3.eth.accounts.create(uuidv4());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test("can get past logs of an account", async (t: Test) => {
*
* @see https://github.com/hyperledger/besu/blob/1.5.1/config/src/main/resources/dev.json
*/
const firstHighNetWorthAccount = "627306090abaB3A6e1400e9345bC60c78a8BEf57";
const firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();

const web3 = new Web3(rpcApiHttpHost);
const testEthAccount = web3.eth.accounts.create(uuidv4());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ test("deploys contract via .json file", async (t: Test) => {
*
* @see https://github.com/hyperledger/besu/blob/1.5.1/config/src/main/resources/dev.json
*/
const firstHighNetWorthAccount = "627306090abaB3A6e1400e9345bC60c78a8BEf57";
const firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();
const besuKeyPair = {
privateKey:
"c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3",
privateKey: besuTestLedger.getGenesisAccountPrivKey(),
};
const contractName = "HelloWorld";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory
const logLevel: LogLevelDesc = "INFO";
const estimatedGas = 6721975;
const expiration = 2147483648;
const receiver = "0x627306090abaB3A6e1400e9345bC60c78a8BEf57";
const besuTestLedger = new BesuTestLedger();
const receiver = "0x" + besuTestLedger.getGenesisAccountPubKey();
const hashLock =
"0x3c335ba7f06a8b01d0596589f73c19069e21c81e5013b91f408165d1bf623d32";
const firstHighNetWorthAccount = "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory
const logLevel: LogLevelDesc = "INFO";
const estimatedGas = 6721975;
const expiration = 2147483648;
const receiver = "0x627306090abaB3A6e1400e9345bC60c78a8BEf57";
const receiver = "0x" + besuTestLedger.getGenesisAccountPubKey();
const hashLock =
"0x3c335ba7f06a8b01d0596589f73c19069e21c81e5013b91f408165d1bf623d32";
const firstHighNetWorthAccount = "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ import HashTimeLockJSON from "../../../../../../cactus-plugin-htlc-eth-besu-erc2
const logLevel: LogLevelDesc = "INFO";
const estimatedGas = 6721975;
const expiration = 2147483648;
const receiver = "0x627306090abaB3A6e1400e9345bC60c78a8BEf57";
const besuTestLedger = new BesuTestLedger();
const receiver = "0x" + besuTestLedger.getGenesisAccountPubKey();
const hashLock =
"0x3c335ba7f06a8b01d0596589f73c19069e21c81e5013b91f408165d1bf623d32";
const firstHighNetWorthAccount = "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ import TestTokenJSON from "../../../solidity/token-erc20-contract/Test_Token.jso
const logLevel: LogLevelDesc = "INFO";
const estimatedGas = 6721975;
const expiration = 2147483648;
const receiver = "0x627306090abaB3A6e1400e9345bC60c78a8BEf57";
const besuTestLedger = new BesuTestLedger();
const receiver = "0x" + besuTestLedger.getGenesisAccountPubKey();
const hashLock =
"0x3c335ba7f06a8b01d0596589f73c19069e21c81e5013b91f408165d1bf623d32";
const firstHighNetWorthAccount = "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ import HashTimeLockJSON from "../../../../../../cactus-plugin-htlc-eth-besu-erc2

const logLevel: LogLevelDesc = "INFO";
const estimatedGas = 6721975;
const receiver = "0x627306090abaB3A6e1400e9345bC60c78a8BEf57";
const besuTestLedger = new BesuTestLedger();
const receiver = "0x" + besuTestLedger.getGenesisAccountPubKey();
const hashLock =
"0x3c335ba7f06a8b01d0596589f73c19069e21c81e5013b91f408165d1bf623d32";
const firstHighNetWorthAccount = "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory
const logLevel: LogLevelDesc = "INFO";
const estimatedGas = 6721975;
const expiration = 2147483648;
const besuTestLedger = new BesuTestLedger();
const secret =
"0x3853485acd2bfc3c632026ee365279743af107a30492e3ceaa7aefc30c2a048a";
const receiver = "0x627306090abaB3A6e1400e9345bC60c78a8BEf57";
const receiver = "0x" + besuTestLedger.getGenesisAccountPubKey();
const hashLock =
"0x3c335ba7f06a8b01d0596589f73c19069e21c81e5013b91f408165d1bf623d32";
const firstHighNetWorthAccount = "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,6 @@ import HashTimeLockJSON from "../../../../../../cactus-plugin-htlc-eth-besu/src/

const connectorId = uuidv4();
const logLevel: LogLevelDesc = "INFO";
const firstHighNetWorthAccount = "627306090abaB3A6e1400e9345bC60c78a8BEf57";
const privateKey =
"c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3";
const web3SigningCredential: Web3SigningCredential = {
ethAccount: firstHighNetWorthAccount,
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const fakeWeb3SigningCredential: Web3SigningCredential = {
ethAccount: "fakeAccount",
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const testCase = "Test get invalid single status";

test("BEFORE " + testCase, async (t: Test) => {
Expand All @@ -73,6 +58,19 @@ test(testCase, async (t: Test) => {

const rpcApiHttpHost = await besuTestLedger.getRpcApiHttpHost();
const rpcApiWsHost = await besuTestLedger.getRpcApiWsHost();
const firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();
const privateKey = besuTestLedger.getGenesisAccountPrivKey();
const web3SigningCredential: Web3SigningCredential = {
ethAccount: firstHighNetWorthAccount,
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const fakeWeb3SigningCredential: Web3SigningCredential = {
ethAccount: "fakeAccount",
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;
const keychainId = uuidv4();
const keychainPlugin = new PluginKeychainMemory({
instanceId: uuidv4(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,6 @@ import HashTimeLockJSON from "../../../../../../cactus-plugin-htlc-eth-besu/src/

const connectorId = uuidv4();
const logLevel: LogLevelDesc = "INFO";
const firstHighNetWorthAccount = "627306090abaB3A6e1400e9345bC60c78a8BEf57";
const privateKey =
"c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3";
const web3SigningCredential: Web3SigningCredential = {
ethAccount: firstHighNetWorthAccount,
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const testCase = "Test get single status";

test("BEFORE " + testCase, async (t: Test) => {
Expand All @@ -68,6 +59,20 @@ test(testCase, async (t: Test) => {

const rpcApiHttpHost = await besuTestLedger.getRpcApiHttpHost();
const rpcApiWsHost = await besuTestLedger.getRpcApiWsHost();
const firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();
const privateKey = besuTestLedger.getGenesisAccountPrivKey();
const web3SigningCredential: Web3SigningCredential = {
ethAccount: firstHighNetWorthAccount,
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const fakeWeb3SigningCredential: Web3SigningCredential = {
ethAccount: "fakeAccount",
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const keychainId = uuidv4();
const keychainPlugin = new PluginKeychainMemory({
instanceId: uuidv4(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,6 @@ import HashTimeLockJSON from "../../../../../../cactus-plugin-htlc-eth-besu/src/

const connectorId = uuidv4();
const logLevel: LogLevelDesc = "INFO";
const firstHighNetWorthAccount = "627306090abaB3A6e1400e9345bC60c78a8BEf57";
const privateKey =
"c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3";
const web3SigningCredential: Web3SigningCredential = {
ethAccount: firstHighNetWorthAccount,
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const testCase = "Test get invalid status";

test("BEFORE " + testCase, async (t: Test) => {
Expand All @@ -68,6 +59,20 @@ test(testCase, async (t: Test) => {

const rpcApiHttpHost = await besuTestLedger.getRpcApiHttpHost();
const rpcApiWsHost = await besuTestLedger.getRpcApiWsHost();
const firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();
const privateKey = besuTestLedger.getGenesisAccountPrivKey();
const web3SigningCredential: Web3SigningCredential = {
ethAccount: firstHighNetWorthAccount,
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const fakeWeb3SigningCredential: Web3SigningCredential = {
ethAccount: "fakeAccount",
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const keychainId = uuidv4();
const keychainPlugin = new PluginKeychainMemory({
instanceId: uuidv4(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ import HashTimeLockJSON from "../../../../../../cactus-plugin-htlc-eth-besu/src/

const connectorId = uuidv4();
const logLevel: LogLevelDesc = "INFO";
const firstHighNetWorthAccount = "627306090abaB3A6e1400e9345bC60c78a8BEf57";
const privateKey =
"c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3";
const web3SigningCredential: Web3SigningCredential = {
ethAccount: firstHighNetWorthAccount,
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const testCase = "Test get status";

Expand All @@ -68,6 +60,20 @@ test(testCase, async (t: Test) => {

const rpcApiHttpHost = await besuTestLedger.getRpcApiHttpHost();
const rpcApiWsHost = await besuTestLedger.getRpcApiWsHost();
const firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();
const privateKey = besuTestLedger.getGenesisAccountPrivKey();
const web3SigningCredential: Web3SigningCredential = {
ethAccount: firstHighNetWorthAccount,
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const fakeWeb3SigningCredential: Web3SigningCredential = {
ethAccount: "fakeAccount",
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const keychainId = uuidv4();
const keychainPlugin = new PluginKeychainMemory({
instanceId: uuidv4(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ import HashTimeLockJSON from "../../../../../../cactus-plugin-htlc-eth-besu/src/

const connectorId = uuidv4();
const logLevel: LogLevelDesc = "INFO";
const firstHighNetWorthAccount = "627306090abaB3A6e1400e9345bC60c78a8BEf57";
const privateKey =
"c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3";
const web3SigningCredential: Web3SigningCredential = {
ethAccount: firstHighNetWorthAccount,
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const testCase = "Test invalid initialize";

Expand All @@ -63,6 +55,20 @@ test(testCase, async (t: Test) => {

const rpcApiHttpHost = await besuTestLedger.getRpcApiHttpHost();
const rpcApiWsHost = await besuTestLedger.getRpcApiWsHost();
const firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();
const privateKey = besuTestLedger.getGenesisAccountPrivKey();
const web3SigningCredential: Web3SigningCredential = {
ethAccount: firstHighNetWorthAccount,
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const fakeWeb3SigningCredential: Web3SigningCredential = {
ethAccount: "fakeAccount",
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const keychainId = uuidv4();
const keychainPlugin = new PluginKeychainMemory({
instanceId: uuidv4(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@ import HashTimeLockJSON from "../../../../../../cactus-plugin-htlc-eth-besu/src/

const connectorId = uuidv4();
const logLevel: LogLevelDesc = "INFO";
const firstHighNetWorthAccount = "627306090abaB3A6e1400e9345bC60c78a8BEf57";
const privateKey =
"c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3";
const web3SigningCredential: Web3SigningCredential = {
ethAccount: firstHighNetWorthAccount,
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const testCase = "Test initialize";

test("BEFORE " + testCase, async (t: Test) => {
Expand All @@ -63,6 +54,19 @@ test(testCase, async (t: Test) => {

const rpcApiHttpHost = await besuTestLedger.getRpcApiHttpHost();
const rpcApiWsHost = await besuTestLedger.getRpcApiWsHost();
const firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();
const privateKey = besuTestLedger.getGenesisAccountPrivKey();
const web3SigningCredential: Web3SigningCredential = {
ethAccount: firstHighNetWorthAccount,
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const fakeWeb3SigningCredential: Web3SigningCredential = {
ethAccount: "fakeAccount",
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;
const keychainId = uuidv4();
const keychainPlugin = new PluginKeychainMemory({
instanceId: uuidv4(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@ import HashTimeLockJSON from "../../../../../../cactus-plugin-htlc-eth-besu/src/

const connectorId = uuidv4();
const logLevel: LogLevelDesc = "INFO";
const firstHighNetWorthAccount = "627306090abaB3A6e1400e9345bC60c78a8BEf57";
const privateKey =
"c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3";
const web3SigningCredential: Web3SigningCredential = {
ethAccount: firstHighNetWorthAccount,
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const testCase = "Test invalid new contract";

Expand All @@ -67,6 +59,20 @@ test(testCase, async (t: Test) => {

const rpcApiHttpHost = await besuTestLedger.getRpcApiHttpHost();
const rpcApiWsHost = await besuTestLedger.getRpcApiWsHost();
const firstHighNetWorthAccount = besuTestLedger.getGenesisAccountPubKey();
const privateKey = besuTestLedger.getGenesisAccountPrivKey();
const web3SigningCredential: Web3SigningCredential = {
ethAccount: firstHighNetWorthAccount,
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const fakeWeb3SigningCredential: Web3SigningCredential = {
ethAccount: "fakeAccount",
secret: privateKey,
type: Web3SigningCredentialType.PrivateKeyHex,
} as Web3SigningCredential;

const keychainId = uuidv4();
const keychainPlugin = new PluginKeychainMemory({
instanceId: uuidv4(),
Expand Down
Loading

0 comments on commit 5811935

Please sign in to comment.