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

Commit

Permalink
Merge branch 'issue_300' of https://github.com/sogoiii/testrpc into s…
Browse files Browse the repository at this point in the history
…ogoiii-issue_300
  • Loading branch information
tcoulter committed Aug 21, 2017
2 parents 1fb0299 + e031d3b commit 0125c81
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/subproviders/geth_api_double.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,26 @@ GethApiDouble.prototype.eth_uninstallFilter = function(filter_id, callback) {
callback(null, true);
};

GethApiDouble.prototype.eth_protocolVersion = function(callback) {
callback(null, "63");
};

GethApiDouble.prototype.personal_listAccounts = function(callback) {
callback(null, Object.keys(this.state.accounts));
};

GethApiDouble.prototype.bzz_hive = function(callback) {
callback(null, []);
};

GethApiDouble.prototype.bzz_info = function(callback) {
callback(null, []);
};

GethApiDouble.prototype.shh_version = function(callback) {
callback(null, "2");
};

GethApiDouble.prototype.eth_getCompilers = function(callback) {
callback(null, ["solidity"]);
}
Expand Down
12 changes: 12 additions & 0 deletions test/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ describe("Accounts", function() {
});
});

it("should be equal (getListAccounts) and (getAccounts)", function(done) {
var web3 = new Web3();
web3.setProvider(TestRPC.provider());
web3.personal.getListAccounts(function(err, listAccounts) {
if (err) return done(err);
web3.eth.getAccounts(function(err, getAccounts){
assert.deepEqual(listAccounts, getAccounts);
done();
})
});
});

it("should lock all accounts when specified", function(done) {
var web3 = new Web3();
web3.setProvider(TestRPC.provider({
Expand Down
21 changes: 21 additions & 0 deletions test/ethereum.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
var Web3 = require('web3');
var assert = require('assert');
var TestRPC = require("../index.js");


describe("Ethereum", function(done) {
var web3 = new Web3();
var provider;

before("Initialize the provider", function() {
provider = TestRPC.provider();
web3.setProvider(provider);
});

it("should get ethereum version (eth_protocolVersion)", function(done) {
web3.version.getEthereum(function(err, result){
assert.equal(result, "63", "Network Version should be 63");
done();
})
});
});
27 changes: 27 additions & 0 deletions test/swarm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
var Web3 = require('web3');
var assert = require('assert');
var TestRPC = require("../index.js");

describe("Swarm", function(done) {
var web3 = new Web3();
var provider;

before("Initialize the provider", function() {
provider = TestRPC.provider();
web3.setProvider(provider);
});

it.skip("should get swarm info (bzz_info)", function(done) {
web3.bzz.getInfo(function(err, result){
assert.isArray(result, "Stub returns empty array")
done();
})
});

it.skip("should get swarm hive (bzz_hive)", function(done) {
web3.bzz.getHive(function(err, result){
assert.isArray(result, "Stub returns empty array")
done();
})
});
});
20 changes: 20 additions & 0 deletions test/whisper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
var Web3 = require('web3');
var assert = require('assert');
var TestRPC = require("../index.js");

describe("Whisper", function(done) {
var web3 = new Web3();
var provider;

before("Initialize the provider", function() {
provider = TestRPC.provider();
web3.setProvider(provider);
});

it("should call get whisper version (shh_version)", function(done) {
web3.version.getWhisper(function(err, result){
assert.equal(result, "2", "Whisper version should be 2");
done();
})
});
});

0 comments on commit 0125c81

Please sign in to comment.