connectionAllowed and permissioning genesis file (#20)

pull/22/head
Lucas Saldanha 6 years ago committed by GitHub
parent c1b2bccf36
commit 0cc7d2650b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      contracts/Ingress.sol
  2. 2
      contracts/Rules.sol
  3. 2
      contracts/RulesProxy.sol
  4. 48
      genesis.json
  5. 20
      test/test-rules-proxy.js
  6. 8
      test/test-rules.js

@ -90,7 +90,7 @@ contract Ingress {
}
}
function isConnectionAllowed(
function connectionAllowed(
bytes32 sourceEnodeHigh,
bytes32 sourceEnodeLow,
bytes16 sourceEnodeIp,
@ -100,7 +100,7 @@ contract Ingress {
bytes16 destinationEnodeIp,
uint16 destinationEnodePort
) public view returns (bool) {
return RulesProxy(registry[RULES_CONTRACT].contractAddress).isConnectionAllowed(
return RulesProxy(registry[RULES_CONTRACT].contractAddress).connectionAllowed(
sourceEnodeHigh,
sourceEnodeLow,
sourceEnodeIp,

@ -113,7 +113,7 @@ contract Rules is AdminProxy, RulesProxy {
}
// RULES - IS CONNECTION ALLOWED
function isConnectionAllowed(
function connectionAllowed(
bytes32 sourceEnodeHigh,
bytes32 sourceEnodeLow,
bytes16 sourceEnodeIp,

@ -1,7 +1,7 @@
pragma solidity >=0.4.22 <0.6.0;
interface RulesProxy {
function isConnectionAllowed(
function connectionAllowed(
bytes32 sourceEnodeHigh,
bytes32 sourceEnodeLow,
bytes16 sourceEnodeIp,

File diff suppressed because one or more lines are too long

@ -35,8 +35,8 @@ contract ('Ingress contract with Rules proxy', () => {
assert.equal(result, rcProxy.address, 'Rules contract has NOT been registered correctly');
// Verify that the nodes are not permitted to talk
result = await icProxy.isConnectionAllowed(node1High, node1Low, node1Host, node1Port, node2High, node2Low, node2Host, node2Port);
result2 = await rcProxy.isConnectionAllowed(node1High, node1Low, node1Host, node1Port, node2High, node2Low, node2Host, node2Port);
result = await icProxy.connectionAllowed(node1High, node1Low, node1Host, node1Port, node2High, node2Low, node2Host, node2Port);
result2 = await rcProxy.connectionAllowed(node1High, node1Low, node1Host, node1Port, node2High, node2Low, node2Host, node2Port);
// assert.equal(result, false, "Connection should NOT be allowed before Enodes have been registered");
assert.equal(result, result2, "Call and proxy call did NOT return the same value");
@ -45,8 +45,8 @@ contract ('Ingress contract with Rules proxy', () => {
result = await rcProxy.addEnode(node2High, node2Low, node2Host, node2Port);
// Verify that the nodes are now able to talk
result = await icProxy.isConnectionAllowed(node1High, node1Low, node1Host, node1Port, node2High, node2Low, node2Host, node2Port);
result2 = await rcProxy.isConnectionAllowed(node1High, node1Low, node1Host, node1Port, node2High, node2Low, node2Host, node2Port);
result = await icProxy.connectionAllowed(node1High, node1Low, node1Host, node1Port, node2High, node2Low, node2Host, node2Port);
result2 = await rcProxy.connectionAllowed(node1High, node1Low, node1Host, node1Port, node2High, node2Low, node2Host, node2Port);
assert.equal(result, true, "Connection SHOULD be allowed after Enodes have been registered");
assert.equal(result, result2, "Call and proxy call did NOT return the same value");
});
@ -76,8 +76,8 @@ contract ('Ingress contract with Rules proxy', () => {
assert.equal(web3.utils.toDecimal(result), 1000000, 'Initial contract is NOT the correct version');
// Verify that the nodes are not permitted to talk
result = await icProxy.isConnectionAllowed(node1High, node1Low, node1Host, node1Port, node2High, node2Low, node2Host, node2Port);
result2 = await rcProxy1.isConnectionAllowed(node1High, node1Low, node1Host, node1Port, node2High, node2Low, node2Host, node2Port);
result = await icProxy.connectionAllowed(node1High, node1Low, node1Host, node1Port, node2High, node2Low, node2Host, node2Port);
result2 = await rcProxy1.connectionAllowed(node1High, node1Low, node1Host, node1Port, node2High, node2Low, node2Host, node2Port);
assert.equal(result, false, "Connection should NOT be allowed before Enodes have been registered");
assert.equal(result, result2, "Call and proxy call did NOT return the same value");
@ -86,8 +86,8 @@ contract ('Ingress contract with Rules proxy', () => {
result = await rcProxy1.addEnode(node2High, node2Low, node2Host, node2Port);
// Verify that the nodes are now able to talk
result = await icProxy.isConnectionAllowed(node1High, node1Low, node1Host, node1Port, node2High, node2Low, node2Host, node2Port);
result2 = await rcProxy1.isConnectionAllowed(node1High, node1Low, node1Host, node1Port, node2High, node2Low, node2Host, node2Port);
result = await icProxy.connectionAllowed(node1High, node1Low, node1Host, node1Port, node2High, node2Low, node2Host, node2Port);
result2 = await rcProxy1.connectionAllowed(node1High, node1Low, node1Host, node1Port, node2High, node2Low, node2Host, node2Port);
assert.equal(result, true, "Connection SHOULD be allowed after Enodes have been registered");
assert.equal(result, result2, "Call and proxy call did NOT return the same value");
@ -104,8 +104,8 @@ contract ('Ingress contract with Rules proxy', () => {
assert.equal(web3.utils.toDecimal(result), 1000000, 'Updated contract is NOT the correct version');
// Verify that the nodes are not permitted to talk
result = await icProxy.isConnectionAllowed(node1High, node1Low, node1Host, node1Port, node2High, node2Low, node2Host, node2Port);
result2 = await rcProxy2.isConnectionAllowed(node1High, node1Low, node1Host, node1Port, node2High, node2Low, node2Host, node2Port);
result = await icProxy.connectionAllowed(node1High, node1Low, node1Host, node1Port, node2High, node2Low, node2Host, node2Port);
result2 = await rcProxy2.connectionAllowed(node1High, node1Low, node1Host, node1Port, node2High, node2Low, node2Host, node2Port);
assert.equal(result, false, "Connection should NOT be allowed before Enodes have been registered");
assert.equal(result, result2, "Call and proxy call did NOT return the same value");
});

@ -64,11 +64,11 @@ contract('Permissioning WITH AUTHORITY ', () => {
});
it('Should allow a connection between 2 added nodes', async () => {
let permitted = await proxy.isConnectionAllowed(node1High, node1Low, node1Host, node1Port, node2High, node2Low, node2Host, node2Port);
let permitted = await proxy.connectionAllowed(node1High, node1Low, node1Host, node1Port, node2High, node2Low, node2Host, node2Port);
assert.equal(permitted, true, 'expected permitted node1 <> node2');
permitted = await proxy.isConnectionAllowed(node1High, node1Low, node1Host, node1Port, node3High, node3Low, node3Host, node3Port);
permitted = await proxy.connectionAllowed(node1High, node1Low, node1Host, node1Port, node3High, node3Low, node3Host, node3Port);
assert.equal(permitted, true, 'expected permitted node1 <> node3');
permitted = await proxy.isConnectionAllowed(node2High, node2Low, node2Host, node2Port, node3High, node3Low, node3Host, node3Port);
permitted = await proxy.connectionAllowed(node2High, node2Low, node2Host, node2Port, node3High, node3Low, node3Host, node3Port);
assert.equal(permitted, true, 'expected permitted node2 <> node3');
});
@ -77,7 +77,7 @@ contract('Permissioning WITH AUTHORITY ', () => {
let permitted = await proxy.enodeAllowed(node1High, node1Low, node1Host, node1Port);
assert.equal(permitted, false, 'expected removed node NOT permitted');
permitted = await proxy.isConnectionAllowed(node1High, node1Low, node1Host, node1Port, node2High, node2Low, node2Host, node2Port);
permitted = await proxy.connectionAllowed(node1High, node1Low, node1Host, node1Port, node2High, node2Low, node2Host, node2Port);
assert.equal(permitted, false, 'expected source disallowed since it was removed');
});
});

Loading…
Cancel
Save