Skip to content

Tests for small network#29

Merged
marc-casperlabs merged 19 commits intocasper-network:masterfrom
marc-casperlabs:NDRS-93/test-small_network
Jun 20, 2020
Merged

Tests for small network#29
marc-casperlabs merged 19 commits intocasper-network:masterfrom
marc-casperlabs:NDRS-93/test-small_network

Conversation

@marc-casperlabs
Copy link
Contributor

@marc-casperlabs marc-casperlabs commented Jun 17, 2020

This PR brings some drastic changes on how the reactor is run: Instead of having a mostly opaque run function, we now use a state-preserving Runner instead that can be interrupted.

This changes little for production use, but it makes it possible to interrupt and resume event processing of a reactor, controlling its progress from the outside (sans IO tasks). This is very useful when writing tests, which can be expressed very naturally:

   let mut net = Network::new();

    net.add_node().await.unwrap();
    net.add_node().await.unwrap();

    timeout(
        Duration::from_millis(1000),
        net.settle_on(network_is_complete),
    )
    .await
    .expect("network did not fully connect in time");

This PR demonstrates how to do that, for an example look at tests.rs of small_network, which implements a tiny testing reactor and a networking structure that can run many of these.

Other notes:

  • The tests aren't completing successfully at the moment every time, which I might be due to bugs in either the testing code or small_net itself, this is naturally the next item to be fixed.
  • The testing code for the network and some other functions from small_net's test.rs could be reused for testing other components, as it provides a generic interface for running multiple nodes until a condition holds true.
  • The next step is usually adding model-based/property-based testing, for example generating a series of events to execute ("Node A joins", "Node B joins", "Node C joins", "Settle", "Node B drops") and checking whether the invariant (network fully connected) holds. These sequences can be randomly generated. With a bit of effort, it should be possible to have robust set of networking tests this way.

Naturally this PR is still a WIP.

This has turned up a few issues already that were present before, but I want to fix these in subsequent PRs.

}

impl Reactor for TestReactor {
type Event = Event;
Copy link
Contributor

@goral09 goral09 Jun 17, 2020

Choose a reason for hiding this comment

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

I think this shows a downside of the current reactor encoding - namely that the Event is an associated type. It means that dispatch_event is dependent on the type of the Event and it will influence how the events are dispatched - where they go, how they're handled (delayed, rejected, etc) but this won't let us test the system as it will run in production. We would be testing a "test reactor".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's fine, I think. We're not testing the reactor here, but the networking component!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So having a bespoke reactor just for doing that seems entirely reasonable to me. Consider it a test rig for a part. When testing car engines, they're initially not put in a car, but on a test stand!

@marc-casperlabs marc-casperlabs changed the title WIP: Test small network Tests for small network Jun 19, 2020
@marc-casperlabs marc-casperlabs merged commit 7759ba4 into casper-network:master Jun 20, 2020
@marc-casperlabs marc-casperlabs deleted the NDRS-93/test-small_network branch June 20, 2020 12:41
mpapierski pushed a commit to mpapierski/casper-node that referenced this pull request Feb 9, 2022
29: Temporarily limit trie leaf size r=mpapierski a=Fraser999

This PR introduces a temporary limit on the maximum size for a trie leaf.  The limit is expected to be removed again in the next node release, as it will have served its purpose of providing a known upper limit on all trie leafs which will exist at the point of upgrading to the subsequent version.

There are four special cases where the limit only generates a log warning but still executes for calls which must not fail under any circumstances.  These call through to `TrackingCopy::force_write`, and with the upcoming restrictions to be applied to the auction contract, should never actually exceed the specified limit.

Closes [casper-network#2605](casper-network#2605).

Co-authored-by: Fraser Hutchison <fraser@casperlabs.io>
Co-authored-by: Michał Papierski <michal@casperlabs.io>
casperlabs-bors-ng bot pushed a commit that referenced this pull request Apr 25, 2024
scratch state: use a BTreeMap for tracking keys in the cache
rafal-ch pushed a commit that referenced this pull request Sep 11, 2024
rafal-ch pushed a commit that referenced this pull request Sep 11, 2024
rafal-ch pushed a commit that referenced this pull request Sep 11, 2024
zajko added a commit to zajko/casper-node that referenced this pull request Oct 13, 2025
# This is the 1st commit message:

rebasing

# The commit message #2 will be skipped:

# WIP

# The commit message #3 will be skipped:

# WIP

# The commit message #4 will be skipped:

# wip

# The commit message #5 will be skipped:

# wip

# The commit message #6 will be skipped:

# wip

# The commit message #7 will be skipped:

# wip

# The commit message #8 will be skipped:

# wip

# The commit message #9 will be skipped:

# wip

# The commit message casper-network#10 will be skipped:

# wip

# The commit message casper-network#11 will be skipped:

# wip

# The commit message casper-network#12 will be skipped:

# wip

# The commit message casper-network#13 will be skipped:

# rebasing

# The commit message casper-network#14 will be skipped:

# wip

# The commit message casper-network#15 will be skipped:

# wip

# The commit message casper-network#16 will be skipped:

# wip

# The commit message casper-network#17 will be skipped:

# wip

# The commit message casper-network#18 will be skipped:

# wip

# The commit message casper-network#19 will be skipped:

# wip

# The commit message casper-network#20 will be skipped:

# rebasing

# The commit message casper-network#21 will be skipped:

# wip

# The commit message casper-network#22 will be skipped:

# wip

# The commit message casper-network#23 will be skipped:

# wip

# The commit message casper-network#24 will be skipped:

# wip

# The commit message casper-network#25 will be skipped:

# wip

# The commit message casper-network#26 will be skipped:

# wip

# The commit message casper-network#27 will be skipped:

# wip

# The commit message casper-network#28 will be skipped:

# wip

# The commit message casper-network#29 will be skipped:

# wip
zajko added a commit to zajko/casper-node that referenced this pull request Oct 13, 2025
# This is the 1st commit message:

rebasing

# The commit message #2 will be skipped:

# WIP

# The commit message #3 will be skipped:

# WIP

# The commit message #4 will be skipped:

# wip

# The commit message #5 will be skipped:

# wip

# The commit message #6 will be skipped:

# wip

# The commit message #7 will be skipped:

# wip

# The commit message #8 will be skipped:

# wip

# The commit message #9 will be skipped:

# wip

# The commit message casper-network#10 will be skipped:

# wip

# The commit message casper-network#11 will be skipped:

# wip

# The commit message casper-network#12 will be skipped:

# wip

# The commit message casper-network#13 will be skipped:

# rebasing

# The commit message casper-network#14 will be skipped:

# wip

# The commit message casper-network#15 will be skipped:

# wip

# The commit message casper-network#16 will be skipped:

# wip

# The commit message casper-network#17 will be skipped:

# wip

# The commit message casper-network#18 will be skipped:

# wip

# The commit message casper-network#19 will be skipped:

# wip

# The commit message casper-network#20 will be skipped:

# rebasing

# The commit message casper-network#21 will be skipped:

# wip

# The commit message casper-network#22 will be skipped:

# wip

# The commit message casper-network#23 will be skipped:

# wip

# The commit message casper-network#24 will be skipped:

# wip

# The commit message casper-network#25 will be skipped:

# wip

# The commit message casper-network#26 will be skipped:

# wip

# The commit message casper-network#27 will be skipped:

# wip

# The commit message casper-network#28 will be skipped:

# wip

# The commit message casper-network#29 will be skipped:

# wip

# The commit message casper-network#30 will be skipped:

# wip

# The commit message casper-network#31 will be skipped:

# wip

# The commit message casper-network#32 will be skipped:

# wip
zajko added a commit to zajko/casper-node that referenced this pull request Oct 13, 2025
# This is the 1st commit message:

rebasing

# The commit message #2 will be skipped:

# WIP

# The commit message #3 will be skipped:

# WIP

# The commit message #4 will be skipped:

# wip

# The commit message #5 will be skipped:

# wip

# The commit message #6 will be skipped:

# wip

# The commit message #7 will be skipped:

# wip

# The commit message #8 will be skipped:

# wip

# The commit message #9 will be skipped:

# wip

# The commit message casper-network#10 will be skipped:

# wip

# The commit message casper-network#11 will be skipped:

# wip

# The commit message casper-network#12 will be skipped:

# wip

# The commit message casper-network#13 will be skipped:

# rebasing

# The commit message casper-network#14 will be skipped:

# wip

# The commit message casper-network#15 will be skipped:

# wip

# The commit message casper-network#16 will be skipped:

# wip

# The commit message casper-network#17 will be skipped:

# wip

# The commit message casper-network#18 will be skipped:

# wip

# The commit message casper-network#19 will be skipped:

# wip

# The commit message casper-network#20 will be skipped:

# rebasing

# The commit message casper-network#21 will be skipped:

# wip

# The commit message casper-network#22 will be skipped:

# wip

# The commit message casper-network#23 will be skipped:

# wip

# The commit message casper-network#24 will be skipped:

# wip

# The commit message casper-network#25 will be skipped:

# wip

# The commit message casper-network#26 will be skipped:

# wip

# The commit message casper-network#27 will be skipped:

# wip

# The commit message casper-network#28 will be skipped:

# wip

# The commit message casper-network#29 will be skipped:

# wip

# The commit message casper-network#30 will be skipped:

# wip

# The commit message casper-network#31 will be skipped:

# wip

# The commit message casper-network#32 will be skipped:

# wip

# The commit message casper-network#33 will be skipped:

# wip

# The commit message casper-network#34 will be skipped:

# wip

# The commit message casper-network#35 will be skipped:

# wip

# The commit message casper-network#36 will be skipped:

# wip

# The commit message casper-network#37 will be skipped:

# wip

# The commit message casper-network#38 will be skipped:

# wip

# The commit message casper-network#39 will be skipped:

# wip

# The commit message casper-network#40 will be skipped:

# rebasing
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.

3 participants