Add registered call
This commit is contained in:
parent
9c5b5be8d5
commit
de5fa5f6ec
|
@ -70,6 +70,14 @@ contract NodesV2
|
|||
inactiveNodeIndex[msg.sender] = inactiveNodes.length;
|
||||
}
|
||||
|
||||
function registered(bytes memory publicKey)
|
||||
public
|
||||
view
|
||||
returns (bool) {
|
||||
address node = publicKeyToAddress(publicKey);
|
||||
return !(activeNodeIndex[node] == 0 && inactiveNodeIndex[node] == 0);
|
||||
}
|
||||
|
||||
function activeNodeCount() public view returns (uint) {
|
||||
return activeNodes.length;
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -124,6 +124,22 @@ contract('Nodes', async (accounts) => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('registered', async () => {
|
||||
beforeEach(async () => {
|
||||
await instance.registerNode(node1.pk, node1.ip, node1.port);
|
||||
});
|
||||
|
||||
it('it returns true when node is registered', async () => {
|
||||
const response = await instance.registered(node1.pk);
|
||||
assert.equal(true, response);
|
||||
});
|
||||
|
||||
it('it returns true when node is registered', async () => {
|
||||
const response = await instance.registered(node2.pk);
|
||||
assert.equal(false, response);
|
||||
});
|
||||
});
|
||||
|
||||
describe('vote', async () => {
|
||||
describe('first round of voting', async () => {
|
||||
// Node1, Node2 and Node3 are active, Node4 is inactive
|
||||
|
|
Loading…
Reference in New Issue