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

Reduced standard time for tests #649

Merged
merged 23 commits into from
Mar 27, 2019

Conversation

igormcoelho
Copy link
Contributor

This is an alternative to: #647

This implies the we will always use standard lower times (2 or 3 seconds). On practice, it's nearly impossible to use 15 seconds for any practical tests. However, we must decide a direction: single unit tests or multiple unit tests.

neo.UnitTests/protocol.json Outdated Show resolved Hide resolved
@jsolman
Copy link
Contributor

jsolman commented Mar 20, 2019

I am definitely in favor of this. Unit tests should test the behavior of the code not really specific to a particular configuration. Integration tests are where specific configuration is tested, such as what is performed by NGD. Unit tests should be written to execute in optimal time, so they do not hold up CI.

{
ProtocolSettings.Default.SecondsPerBlock.Should().Be(2);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This redundant test made everything fail now.. lol time to fix old tests.

neo.UnitTests/UT_Consensus.cs Outdated Show resolved Hide resolved
jsolman
jsolman previously approved these changes Mar 21, 2019
@@ -57,12 +57,13 @@ public void ConsensusService_Primary_Sends_PrepareRequest_After_OnStart()

int timeIndex = 0;
var timeValues = new[] {
new DateTime(1968, 06, 01, 0, 0, 15, DateTimeKind.Utc), // For tests here
//new DateTime(1968, 06, 01, 0, 0, 15, DateTimeKind.Utc), // For tests here
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the commented line?

Copy link
Contributor Author

@igormcoelho igormcoelho Mar 21, 2019

Choose a reason for hiding this comment

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

I removed it from array and also one consuming test below, just to make it simpler... in fact, some parts of this test can be improved in the future, or even split into many smaller tests. After we start writing other tests, we will re-write this one from scratch.
The main reason is because time was going back, and I don't like this anymore 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we still just remove the commented line altogether?

@@ -93,7 +94,6 @@ public void ConsensusService_Primary_Sends_PrepareRequest_After_OnStart()
Console.WriteLine($"header {header} hash {header.Hash} timstamp {timestampVal}");

timestampVal.Should().Be(4244941696); //1968-06-01 00:00:00
TimeProvider.Current.UtcNow.ToTimestamp().Should().Be(4244941711); //1968-06-01 00:00:15
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this consumption was removed here too... but I can make it back if you prefer. We will re-write everything here as soon as we decide upon these fast tests.

@igormcoelho
Copy link
Contributor Author

igormcoelho commented Mar 24, 2019

Ok, I agree with @erikzhang and @jsolman , now anything is attached to the time on protocol.json file. We can change it freely ;) Is that ok?
This still ensures time is bound to 2 seconds on Unit Tests, that's enough for me.

"127.0.0.1:20334",
"127.0.0.1:20335",
"127.0.0.1:20336",
"127.0.0.1:20337",
Copy link
Member

Choose a reason for hiding this comment

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

Why 127.0.0.1?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just put localhost, to make sure it won't try to connect to any external ip during tests. Any suggestions?

Copy link
Member

Choose a reason for hiding this comment

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

Does this test need to start additional nodes?

Copy link
Member

Choose a reason for hiding this comment

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

Now that protocol.json is not required, we can remove most of the options, leaving only SecondsPerBlock.

Copy link
Contributor Author

@igormcoelho igormcoelho Mar 27, 2019

Choose a reason for hiding this comment

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

Thanks a lot for that Erik. I'll update the tests.

@igormcoelho
Copy link
Contributor Author

Ok, I just kept Block Time (2 seconds) and also StandbyValidators, because we are using these exact values on UT_Consensus. However, by doing that, I broke something.

@igormcoelho
Copy link
Contributor Author

Ok, now it's working. I just left block time (2 seconds), because validators are being entered manually on UT_Consensus.

is it good for you guys @erikzhang @shargon @jsolman ?

[TestMethod]
public void Test_Standby_Validators()
{
// Using Random values
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 need to include all this commented out code now? Either add it later when it is used? Or add it now if it is ready?

neo.UnitTests/UT_Consensus.cs Show resolved Hide resolved
@@ -57,12 +57,13 @@ public void ConsensusService_Primary_Sends_PrepareRequest_After_OnStart()

int timeIndex = 0;
var timeValues = new[] {
new DateTime(1968, 06, 01, 0, 0, 15, DateTimeKind.Utc), // For tests here
//new DateTime(1968, 06, 01, 0, 0, 15, DateTimeKind.Utc), // For tests here
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we still just remove the commented line altogether?

@igormcoelho igormcoelho merged commit 1ed6ecc into neo-project:master Mar 27, 2019
@igormcoelho igormcoelho deleted the test-fast-time branch March 27, 2019 15:03
Thacryba pushed a commit to simplitech/neo that referenced this pull request Feb 17, 2020
`dotnet new library` generates an error with dotnet version 2.1.402
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants