Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3916 from gitpurva/develop
Browse files Browse the repository at this point in the history
Renamed snake_case to camelCase at desired files
  • Loading branch information
haltman-at authored Mar 12, 2021
2 parents 7956171 + 1a3b17a commit 33f574c
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 75 deletions.
4 changes: 2 additions & 2 deletions packages/artifactor/test/customoptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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");
Expand Down
8 changes: 4 additions & 4 deletions packages/blockchain-utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,19 @@ 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",
provider,
(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
Expand Down
6 changes: 3 additions & 3 deletions packages/compile-vyper/test/test_compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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"
);

Expand Down
12 changes: 6 additions & 6 deletions packages/contract-tests/test/networkObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
);
});
Expand Down
16 changes: 8 additions & 8 deletions packages/contract/lib/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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, ""))
Expand All @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
16 changes: 8 additions & 8 deletions packages/core/test/ethpm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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.
Expand Down
84 changes: 42 additions & 42 deletions packages/resolver/test/globalnpm.ts
Original file line number Diff line number Diff line change
@@ -1,113 +1,113 @@
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, {});
});

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"
);

Expand All @@ -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"
);

Expand All @@ -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();
});
});
});

0 comments on commit 33f574c

Please sign in to comment.