diff --git a/packages/artifactor/test/customoptions.js b/packages/artifactor/test/customoptions.js index 7a1b22cee0a..795f02b1b89 100644 --- a/packages/artifactor/test/customoptions.js +++ b/packages/artifactor/test/customoptions.js @@ -14,7 +14,7 @@ describe("Custom options", () => { prefix: "tmp-test-contract-", }); - const expected_filepath = path.join(tempDir.name, "Example.json"); + const expectedFilepath = path.join(tempDir.name, "Example.json"); artifactor = new Artifactor(tempDir.name); @@ -29,7 +29,7 @@ describe("Custom options", () => { "x-from-dependency": "somedep", }) .then(() => { - const json = requireNoCache(expected_filepath); + const json = requireNoCache(expectedFilepath); Example = contract(json); assert.equal(Example["x-from-dependency"], "somedep"); diff --git a/packages/blockchain-utils/index.ts b/packages/blockchain-utils/index.ts index d92266d84c8..5c12b94d325 100644 --- a/packages/blockchain-utils/index.ts +++ b/packages/blockchain-utils/index.ts @@ -84,8 +84,8 @@ const Blockchain = { return new Promise((resolve, reject) => { const parsedUri = this.parse(uri); - const expected_genesis = parsedUri.genesis_hash; - const expected_block = parsedUri.block_hash; + const expectedGenesis = parsedUri.genesis_hash; + const expectedBlock = parsedUri.block_hash; this.getBlockByNumber( "0x0", @@ -93,10 +93,10 @@ const Blockchain = { (err: Error, { result }: JsonRPCResponse) => { if (err) return reject(err); const block = result; - if (block.hash !== expected_genesis) return resolve(false); + if (block.hash !== expectedGenesis) return resolve(false); this.getBlockByHash( - expected_block, + expectedBlock, provider, (err: Error, { result }: JsonRPCResponse) => { // Treat an error as if the block didn't exist. This is because diff --git a/packages/compile-vyper/test/test_compiler.js b/packages/compile-vyper/test/test_compiler.js index c2a4ee3b7e6..4d5ca5fb23b 100644 --- a/packages/compile-vyper/test/test_compiler.js +++ b/packages/compile-vyper/test/test_compiler.js @@ -29,7 +29,7 @@ describe("vyper compiler", function () { ); }); - const hex_regex = /^([0-9a-fA-F]{2})*$/; + const hexRegex = /^([0-9a-fA-F]{2})*$/; contracts.forEach((contract, index) => { assert.notEqual( @@ -49,11 +49,11 @@ describe("vyper compiler", function () { ); assert( - hex_regex.test(contract.bytecode.bytes), + hexRegex.test(contract.bytecode.bytes), "Bytecode is a valid hex string w/o prefix" ); assert( - hex_regex.test(contract.deployedBytecode.bytes), + hexRegex.test(contract.deployedBytecode.bytes), "Deployed bytecode is a valid hex string w/o prefix" ); diff --git a/packages/contract-tests/test/networkObject.js b/packages/contract-tests/test/networkObject.js index 4fc47a49740..b0b56d58910 100644 --- a/packages/contract-tests/test/networkObject.js +++ b/packages/contract-tests/test/networkObject.js @@ -3,7 +3,7 @@ var util = require("./util"); describe("Network Object [ @geth ]", function () { var Example; - var network_id; + var networkId; it("errors when setting an invalid provider", function (done) { try { @@ -19,19 +19,19 @@ describe("Network Object [ @geth ]", function () { var NewExample = await util.createExample(); const result = await util.setUpProvider(NewExample); - network_id = await result.web3.eth.net.getId(); + networkId = await result.web3.eth.net.getId(); - assert.equal(NewExample.network_id, null); + assert.equal(NewExample.networkId, null); const example = await NewExample.new(1); // We have a network id in this case, with new(), since it was detected, // but no further configuration. - assert.equal(NewExample.network_id, network_id); - assert.equal(NewExample.toJSON().networks[network_id], null); + assert.equal(NewExample.networkId, networkId); + assert.equal(NewExample.toJSON().networks[networkId], null); NewExample.address = example.address; assert.equal( - NewExample.toJSON().networks[network_id].address, + NewExample.toJSON().networks[networkId].address, example.address ); }); diff --git a/packages/contract/lib/utils/index.js b/packages/contract/lib/utils/index.js index 363fc259fc5..2a99ab27e55 100644 --- a/packages/contract/lib/utils/index.js +++ b/packages/contract/lib/utils/index.js @@ -132,14 +132,14 @@ const Utils = { getTxParams(methodABI, args) { const constructor = this; - const expected_arg_count = methodABI ? methodABI.inputs.length : 0; + const expectedArgCount = methodABI ? methodABI.inputs.length : 0; let tx_params = {}; - const last_arg = args[args.length - 1]; + const lastArg = args[args.length - 1]; if ( - args.length === expected_arg_count + 1 && - Utils.isTxParams(last_arg) + args.length === expectedArgCount + 1 && + Utils.isTxParams(lastArg) ) { tx_params = args.pop(); } @@ -152,10 +152,10 @@ const Utils = { checkLibraries() { const constructor = this; const regex = /__[^_]+_+/g; - let unlinked_libraries = constructor.binary.match(regex); + let unlinkedLibraries = constructor.binary.match(regex); - if (unlinked_libraries !== null) { - unlinked_libraries = unlinked_libraries + if (unlinkedLibraries !== null) { + unlinkedLibraries = unlinkedLibraries .map(( name // Remove underscores ) => name.replace(/_/g, "")) @@ -174,7 +174,7 @@ const Utils = { constructor.contractName } contains unresolved libraries. You must deploy and link the following libraries before you can deploy a new version of ${ constructor.contractName - }: ${unlinked_libraries}`; + }: ${unlinkedLibraries}`; throw new Error(error); } diff --git a/packages/core/exec.js b/packages/core/exec.js index 07b8c2c3142..8294994aa34 100755 --- a/packages/core/exec.js +++ b/packages/core/exec.js @@ -2,9 +2,9 @@ var path = require("path"); var spawn = require("child_process").spawn; -var cli_path = path.resolve(path.join(__dirname, "./cli.js")); +var cliPath = path.resolve(path.join(__dirname, "./cli.js")); -var args = [cli_path, "exec"]; +var args = [cliPath, "exec"]; Array.prototype.push.apply(args, process.argv.slice(2)); diff --git a/packages/core/test/ethpm.js b/packages/core/test/ethpm.js index dd625c950a9..5c4177e8f8a 100644 --- a/packages/core/test/ethpm.js +++ b/packages/core/test/ethpm.js @@ -116,12 +116,12 @@ describe.skip("EthPM integration", function () { packages: ["owned"] }) ); - const expected_install_directory = path.resolve( + const expectedInstallDirectory = path.resolve( path.join(config.working_directory, "installed_contracts", "owned") ); - assertFile(path.join(expected_install_directory, "ethpm.json")); - assertFile(path.join(expected_install_directory, "contracts", "owned.sol")); + assertFile(path.join(expectedInstallDirectory, "ethpm.json")); + assertFile(path.join(expectedInstallDirectory, "contracts", "owned.sol")); }); it("successfully installs and provisions a package with dependencies from EthPM", async function () { @@ -138,24 +138,24 @@ describe.skip("EthPM integration", function () { packages: ["transferable"] }) ); - const expected_install_directory = path.resolve( + const expectedInstallDirectory = path.resolve( path.join(config.working_directory, "installed_contracts") ); assertFile( - path.join(expected_install_directory, "transferable", "ethpm.json") + path.join(expectedInstallDirectory, "transferable", "ethpm.json") ); assertFile( path.join( - expected_install_directory, + expectedInstallDirectory, "transferable", "contracts", "transferable.sol" ) ); - assertFile(path.join(expected_install_directory, "owned", "ethpm.json")); + assertFile(path.join(expectedInstallDirectory, "owned", "ethpm.json")); assertFile( - path.join(expected_install_directory, "owned", "contracts", "owned.sol") + path.join(expectedInstallDirectory, "owned", "contracts", "owned.sol") ); // Write a contract that uses transferable, so it will be compiled. diff --git a/packages/resolver/test/globalnpm.ts b/packages/resolver/test/globalnpm.ts index 18fbe7ea959..967f26ca02d 100644 --- a/packages/resolver/test/globalnpm.ts +++ b/packages/resolver/test/globalnpm.ts @@ -1,51 +1,51 @@ import assert from "assert"; const detectInstalled: any = require("detect-installed"); -const get_installed_path: any = require("get-installed-path"); +const getInstalledPath: any = require("get-installed-path"); import * as sinon from "sinon"; import path from "path"; import fs from "fs"; import { describe, it } from "mocha"; import { GlobalNPM } from "../lib/sources/globalnpm"; -const global_npm = new GlobalNPM(); +const globalNpm = new GlobalNPM(); describe("globalnpm", () => { describe("require function", () => { - let sync_stub: sinon.SinonStub; - let get_installed_path_sync_stub: sinon.SinonStub; + let syncStub: sinon.SinonStub; + let getInstalledPathSyncStub: sinon.SinonStub; beforeEach(() => { - sync_stub = sinon.stub(detectInstalled, "sync"); - get_installed_path_sync_stub = sinon.stub( - get_installed_path, + syncStub = sinon.stub(detectInstalled, "sync"); + getInstalledPathSyncStub = sinon.stub( + getInstalledPath, "getInstalledPathSync" ); }); afterEach(() => { - sync_stub.restore(); - get_installed_path_sync_stub.restore(); + syncStub.restore(); + getInstalledPathSyncStub.restore(); }); it("should return null if the import_path starts with '.'", () => { - const result = global_npm.require("./A.sol"); + const result = globalNpm.require("./A.sol"); assert.deepEqual(result, null); }); it("should return null if the import_path is absolute path", () => { - const result = global_npm.require("/A.sol"); + const result = globalNpm.require("/A.sol"); assert.deepEqual(result, null); }); it("should return the contents of json if the import_path exists", () => { - sync_stub.withArgs("package").returns(true); - get_installed_path_sync_stub + syncStub.withArgs("package").returns(true); + getInstalledPathSyncStub .withArgs("package") .returns( path.resolve(__dirname, "fixtures/globalnpm/node_modules/package") ); - const result = global_npm.require("package/contracts/Test.sol"); + const result = globalNpm.require("package/contracts/Test.sol"); assert.deepEqual(result, {}); }); @@ -53,61 +53,61 @@ describe("globalnpm", () => { it("should return undefined if the import_path does not exist", () => { const read_file_sync_stub = sinon.stub(fs, "readFileSync"); - sync_stub.withArgs("package").returns(false); + syncStub.withArgs("package").returns(false); - const result = global_npm.require("package/contracts/Test.sol"); + const result = globalNpm.require("package/contracts/Test.sol"); - assert.ok(!get_installed_path_sync_stub.called); + assert.ok(!getInstalledPathSyncStub.called); assert.deepEqual(result, undefined); read_file_sync_stub.restore(); }); it("should return null if readFileSync throws Error", () => { - const read_file_sync_stub = sinon.stub(fs, "readFileSync"); + const readFileSyncStub = sinon.stub(fs, "readFileSync"); - sync_stub.withArgs("package").returns(true); - get_installed_path_sync_stub + syncStub.withArgs("package").returns(true); + getInstalledPathSyncStub .withArgs("package") .returns( path.resolve(__dirname, "fixtures/globalnpm/node_modules/package") ); - read_file_sync_stub.throws("some error"); + readFileSyncStub.throws("some error"); - const result = global_npm.require("package/contracts/Test.sol"); + const result = globalNpm.require("package/contracts/Test.sol"); assert.deepEqual(result, null); - read_file_sync_stub.restore(); + readFileSyncStub.restore(); }); }); describe("resolve function", () => { - let sync_stub: sinon.SinonStub; - let get_installed_path_sync_stub: sinon.SinonStub; + let syncStub: sinon.SinonStub; + let getInstalledPathSyncStub: sinon.SinonStub; beforeEach(() => { - sync_stub = sinon.stub(detectInstalled, "sync"); - get_installed_path_sync_stub = sinon.stub( - get_installed_path, + syncStub = sinon.stub(detectInstalled, "sync"); + getInstalledPathSyncStub = sinon.stub( + getInstalledPath, "getInstalledPathSync" ); }); afterEach(() => { - sync_stub.restore(); - get_installed_path_sync_stub.restore(); + syncStub.restore(); + getInstalledPathSyncStub.restore(); }); it("should return the contents of solidity file if the import_path exists", async () => { - sync_stub.withArgs("package").returns(true); - get_installed_path_sync_stub + syncStub.withArgs("package").returns(true); + getInstalledPathSyncStub .withArgs("package") .returns( path.resolve(__dirname, "fixtures/globalnpm/node_modules/package") ); - const { body, filePath } = await global_npm.resolve( + const { body, filePath } = await globalNpm.resolve( "package/contracts/Test.sol" ); @@ -116,14 +116,14 @@ describe("globalnpm", () => { }); it("should return undefined body if the package does not exist", async () => { - sync_stub.withArgs("package").returns(false); - get_installed_path_sync_stub + syncStub.withArgs("package").returns(false); + getInstalledPathSyncStub .withArgs("package") .returns( path.resolve(__dirname, "fixtures/globalnpm/node_modules/package") ); - const { body, filePath } = await global_npm.resolve( + const { body, filePath } = await globalNpm.resolve( "package/contracts/Test.sol" ); @@ -132,24 +132,24 @@ describe("globalnpm", () => { }); it("should return undefined body if readFileSync throws Error", async () => { - const read_file_sync_stub = sinon.stub(fs, "readFileSync"); + const readFileSyncStub = sinon.stub(fs, "readFileSync"); - sync_stub.withArgs("package").returns(true); - get_installed_path_sync_stub + syncStub.withArgs("package").returns(true); + getInstalledPathSyncStub .withArgs("package") .returns( path.resolve(__dirname, "fixtures/globalnpm/node_modules/package") ); - read_file_sync_stub.throws("some error"); + readFileSyncStub.throws("some error"); - const { body, filePath } = await global_npm.resolve( + const { body, filePath } = await globalNpm.resolve( "package/contracts/Test.sol" ); assert.strictEqual(body, undefined); assert.strictEqual(filePath, "package/contracts/Test.sol"); - read_file_sync_stub.restore(); + readFileSyncStub.restore(); }); }); });