Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AKI-449: BlockchainTestUtils functionality to generate random Unity chains #1031

Merged
merged 3 commits into from
Oct 25, 2019

Conversation

AlexandraRoatis
Copy link
Contributor

@AlexandraRoatis AlexandraRoatis commented Oct 23, 2019

Description

  • Extracted common block creation and import into a separate method:
    • number of blocks given as long;
    • printing seed used at the start of the random chain generation;
    • creating chains with blocks without transactions is limited to pre-unity blocks since accounts are required for deploying the staking contract;
  • Allowing the staking contract address and helper to be set for testing.
  • AKI-449: BlockchainTestUtils can generate random Unity chains.

Type of change

  • Bug fix.
  • New feature.
  • Enhancement.
  • Unit test.
  • Breaking change (a fix or feature that causes existing functionality to not work as expected).
  • Requires documentation update.

Testing

  • Verified that chain generation works correctly with different parameters.

@AlexandraRoatis AlexandraRoatis self-assigned this Oct 23, 2019
@AlexandraRoatis AlexandraRoatis added the enhancement New feature or request label Oct 23, 2019
@AlexandraRoatis AlexandraRoatis added this to the 0.5.0 (Unity) milestone Oct 23, 2019
public static void generateRandomUnityChain(
StandaloneBlockchain chain,
TestResourceProvider resourceProvider,
int blocks,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

long

// get the parent seed
byte[] parentSeed = chain.forkUtility.isUnityForkBlock(parent.getNumber())
? chain.getGenesis().getGenesisStakingBlock().getSeed()
: chain.getBestStakingBlock().getSeed();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

add todo for sidechains

* @param accounts existing accounts
* @param txCount maximum number of transactions per block
*/
public static void generateRandomUnityChain(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

add java doc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

print seed at start


private static final BigInteger MIN_SELF_STAKE = new BigInteger("1000000000000000000000");

private static Pair<Block, ImportResult> addMiningBlock(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

check with pre unity

 - number of blocks given as long;
 - printing seed used at the start of the random chain generation;
 - creating chains with blocks without transactions is limited to pre-unity
 blocks since accounts are required for deploying the staking contract;
@AlexandraRoatis AlexandraRoatis force-pushed the AKI-449 branch 2 times, most recently from 4c3ba0c to 258bcd4 Compare October 24, 2019 23:38
@AlexandraRoatis AlexandraRoatis merged commit 258bcd4 into master Oct 25, 2019
@AlexandraRoatis AlexandraRoatis deleted the AKI-449 branch October 25, 2019 01:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant