Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Added Privacy Test Scenario #3 to privacy-simple-network.py #10253

Merged

Conversation

brianjohnson5972
Copy link
Contributor

@brianjohnson5972 brianjohnson5972 commented Apr 16, 2021

Change Description

Added more complex scenarios and covered the Test Scenario #3. Also made improvements to Node and Cluster and pulled in common code.

Change Type

Select ONE:

  • Documentation
  • Stability bug fix
  • Other
  • Other - special case

Testing Changes

Select ANY that apply:

  • New Tests
  • Existing Tests
  • Test Framework
  • CI System
  • Other

Consensus Changes

  • Consensus Changes

API Changes

  • API Changes

Documentation Additions

  • Documentation Additions

@brianjohnson5972 brianjohnson5972 merged commit ca8a056 into feature-privacy Apr 16, 2021
@brianjohnson5972 brianjohnson5972 deleted the bdj__privacy-simple-test-improvements_EPE-832 branch April 16, 2021 19:48

def getParticipantNum(self, nodeToIdentify):
num = 0
for node in self.nodes:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for num, node in zip(range(len(self.nodes)), self.nodes) and dispense with manually initializing and incrementing num.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or alternatively we can do something like this:

range_nodes = range(len(self.nodes))
nodeDict = dict(zip(self.nodes, range_nodes)) | {self.biosNode : self.totalNodes}
return nodeDict[nodeToIndentify]

minBlocksForGuarantee = 2
assert producer not in self.getProducers() or blockNum - headBlockNum < minBlocksForGuarantee, \
"It is {} blocks past the block when we activated the features and block num: {} was produced by this \
node, so features should have been set."
Copy link
Contributor

@jgiszczak jgiszczak Apr 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing format call for block num substitutions.

# feature should be in block for this node's producers, if it is at least 2 blocks after we sent the activate
minBlocksForGuarantee = 2
assert producer not in self.getProducers() or blockNum - headBlockNum < minBlocksForGuarantee, \
"It is {} blocks past the block when we activated the features and block num: {} was produced by this \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for colon after "block num" in message.

producer = block["producer"]
producers[producer] += 1
assert lastProducer != producer or producers[producer] == 1, \
"We have already cycled through a complete cycle, so feature should have been set by now. \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about "Producer schedule cycle completed and feature has not been set. Initial block num: {}, current block num: {}"


producer = block["producer"]
producers[producer] += 1
assert lastProducer != producer or producers[producer] == 1, \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entire assert doesn't seem very useful. It will trigger immediately in a single producer network, and never trigger in a multi-producer network because the second assert below will always trigger first.

# this is passed to limit the number of add/remove table entries are processed, but using it here to keep from getting duplicate transactions
publishProcessNum = 20
def security_group(addNodeNums=[], removeNodeNums=[]):
def createAction(nodeNums):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def createAction(nodeNums):
    return None if len(nodeNums) == 0 else '[[{}]]'.format(','.join(['"{}"'.format(Node.participantName(nodeNum)) for nodeNum in nodeNums]))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those one liners are hard to read.
we can have at least something like that:

def createAction(nodeNums):
     if len(nodeNums) == 0 
         return None
     return '[[{}]]'.format(','.join(['"{}"'.format(Node.participantName(n)) for n in nodeNums]))


while not done and len(participants) > pnodes:
publishTrans = remFromSg()
Utils.Print("publishTrans: {}".format(json.dumps(publishTrans, indent=2)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason indent doesn't match the indent used elsewhere?

brianjohnson5972 added a commit that referenced this pull request Apr 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants