Commit some new networking code, adding integration, broker still not 100%, hasn't been committed
This commit is contained in:
parent
1af6d56e2d
commit
050e69e23f
18 changed files with 1829 additions and 359 deletions
43
blockchain/integration.test.js
Normal file
43
blockchain/integration.test.js
Normal file
|
@ -0,0 +1,43 @@
|
|||
const Integration = require('./integration');
|
||||
const ChainUtil = require('../chain-util');
|
||||
|
||||
function createDummyIntegration(keyPair, witnesses) {
|
||||
return new Integration(
|
||||
keyPair,
|
||||
1,
|
||||
[Integration.createOutput(keyPair.getPublic().encode('hex'), 'a', 5, 1)],
|
||||
witnesses,
|
||||
0);
|
||||
}
|
||||
|
||||
describe('Integration', () => {
|
||||
let keyPair;
|
||||
|
||||
beforeEach(() => {
|
||||
keyPair = ChainUtil.genKeyPair();
|
||||
});
|
||||
|
||||
it("Choose witnesses doesn't care about brokers ordering, 1 witness", () => {
|
||||
const brokers_f = ['a', 'b', 'c'];
|
||||
const brokers_b = ['c', 'b', 'a'];
|
||||
|
||||
const integration = createDummyIntegration(keyPair, 1);
|
||||
expect(Integration.chooseWitnesses(integration, brokers_f)).toEqual(Integration.chooseWitnesses(integration, brokers_b));
|
||||
});
|
||||
|
||||
it("Choose witnesses doesn't care about brokers ordering, 2 witness", () => {
|
||||
const brokers_f = ['a', 'b', 'c'];
|
||||
const brokers_b = ['c', 'b', 'a'];
|
||||
|
||||
const integration = createDummyIntegration(keyPair, 2);
|
||||
expect(Integration.chooseWitnesses(integration, brokers_f)).toEqual(Integration.chooseWitnesses(integration, brokers_b));
|
||||
});
|
||||
|
||||
it("Choose witnesses doesn't care about brokers ordering, 3 witness", () => {
|
||||
const brokers_f = ['a', 'b', 'c'];
|
||||
const brokers_b = ['c', 'b', 'a'];
|
||||
|
||||
const integration = createDummyIntegration(keyPair, 3);
|
||||
expect(Integration.chooseWitnesses(integration, brokers_f)).toEqual(Integration.chooseWitnesses(integration, brokers_b));
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue