Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Fix framework integration test - Closes #6640 #6959

Merged

Conversation

shuse2
Copy link
Collaborator

@shuse2 shuse2 commented Dec 6, 2021

What was the problem?

This PR resolves #6640, resolves #6961 and resolves #6976

How was it solved?

  • Enable framework integration test
  • Make sure the integration test is correct and passing

How was it tested?

Enable integration test

Base automatically changed from 6944-update_genesis_create to feature/6554-improve-framework-architecture January 3, 2022 13:46
@shuse2 shuse2 force-pushed the 6640-fix_integration_test branch from 8705534 to 454e96f Compare January 3, 2022 19:20
@shuse2 shuse2 linked an issue Jan 7, 2022 that may be closed by this pull request
@shuse2 shuse2 force-pushed the 6640-fix_integration_test branch 3 times, most recently from 4aea45a to 77b1e39 Compare January 12, 2022 17:28
@shuse2 shuse2 linked an issue Jan 14, 2022 that may be closed by this pull request
@shuse2 shuse2 self-assigned this Jan 14, 2022
@shuse2 shuse2 requested review from ishantiw and mitsuaki-u January 14, 2022 22:19
- Add Integration test back
- Fix forever loop for SMT
- Fix block generation not executin transaction
- Fix dependency injection
- Fix token API saving invalid object
- Fix genesis asset fixture on test
- Fix fork choice time usage
- Fix auth module verify to expect no data
- Fix reward module to expect no initial value on init
- Fix reward module to not check BFT when reward is zero

:bug: Fix SMT prefix and loop

fix test fixture

fix

fix processor test
@shuse2 shuse2 force-pushed the 6640-fix_integration_test branch from 3f79fc1 to 65682b3 Compare January 14, 2022 22:19
@shuse2 shuse2 marked this pull request as ready for review January 14, 2022 22:19
@@ -22,4 +22,5 @@ export const copyBuffer = (value: Buffer): Buffer => {
};

export const toSMTKey = (value: Buffer): Buffer =>
Buffer.concat([value.slice(0, SMT_PREFIX_SIZE), hash(value.slice(SMT_PREFIX_SIZE))]);
// First byte is the DB prefix
Buffer.concat([value.slice(1, SMT_PREFIX_SIZE + 1), hash(value.slice(SMT_PREFIX_SIZE + 1))]);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Issue #6961

while (binaryKey.charAt(h) === currentNodeBinaryKey.charAt(h)) {
while (
binaryKey.length > h &&
currentNodeBinaryKey.length > h &&
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Without this check, it will go into forever loop when all keys are equal


// First transaction will not have nonce
try {
senderAccount = await store.getWithSchema<AuthAccount>(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sending first transaction will not have auth data set

const store = context.getStore(this.id, STORE_PREFIX_AUTH);
const senderExist = await store.has(transaction.senderAddress);
if (!senderExist) {
await store.setWithSchema(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Creating initial data was missing

@@ -54,6 +54,9 @@ export class ReportDelegateMisbehaviorCommand extends BaseCommand {
this._bftAPI = args.bftAPI;
this._tokenAPI = args.tokenAPI;
this._validatorsAPI = args.validatorsAPI;
}

public init(args: { tokenIDDPoS: TokenIDDPoS }) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Token ID is not dependency and it's only given in the init step in the module

db: this._db,
network: this._network,
validatorsAPI: this._validatorAPI,
generatorAddress: Buffer.alloc(0),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

DB only exist in the init step, so it should be created at the init step

@@ -439,7 +446,7 @@ export class Consensus {
{ id: block.header.id, height: block.header.height },
'Processing valid block',
);
await this._verify(block);
block.validate();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

verification should happen at the later stage

@@ -100,7 +100,7 @@ export const forkChoice = (
// Current time since Lisk Epoch
const receivedBFTHeader = {
...blockHeader.toObject(),
receivedAt: slots.timeSinceGenesis(),
receivedAt: Math.floor(Date.now() / 1000),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

at later stage, receivedAt is used as the received time, not time since genesis

const transactions =
input.transactions ?? (await this._forgingStrategy.getTransactionsForBlock(blockHeader));

blockCtx.setTransactions(transactions);
for (const tx of transactions) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

transaction execution was missing in generator

await this._stateMachine.executeTransaction(txContext);
}

await this._stateMachine.afterExecuteBlock(blockCtx);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Issue #6976

@shuse2 shuse2 linked an issue Jan 15, 2022 that may be closed by this pull request
@shuse2 shuse2 force-pushed the 6640-fix_integration_test branch from 5499c5c to 1bbaced Compare January 17, 2022 13:04
Copy link
Contributor

@ishantiw ishantiw left a comment

Choose a reason for hiding this comment

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

LGTM, some minor comments

Comment on lines 127 to 129
} catch (error) {
return { status: VerifyStatus.FAIL };
return { status: VerifyStatus.FAIL, error: error as Error };
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe,

} catch (error: Error) {
			return { status: VerifyStatus.FAIL, error };
		}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

} catch (error: Error) { doesn't work since typescript type it as any

framework/test/utils/node/account.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@mitsuaki-u mitsuaki-u left a comment

Choose a reason for hiding this comment

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

LGTM! Some minor comment

@shuse2 shuse2 requested review from ishantiw and mitsuaki-u January 18, 2022 18:04
@shuse2 shuse2 force-pushed the 6640-fix_integration_test branch from f20cbee to b7b95b3 Compare January 19, 2022 16:10
@shuse2 shuse2 merged commit 9ff9344 into feature/6554-improve-framework-architecture Jan 19, 2022
@shuse2 shuse2 deleted the 6640-fix_integration_test branch January 19, 2022 16:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants