Skip to content

Discrepancy between seeded and unseeded Testnet nodes #317

@ok300

Description

@ok300

It appears that Testnet::new(n) actually spins up n + 1 nodes.

Consider this test

    #[tokio::test]
    async fn single_key_republish_insufficient() {
        let dht = pkarr::mainline::Testnet::new(3).unwrap();
        let mut pkarr_builder = pkarr::ClientBuilder::default();
        pkarr_builder.bootstrap(&dht.bootstrap).no_relays();
        let pkarr_client = pkarr_builder.clone().build().unwrap();

        let public_keys = publish_sample_packets(&pkarr_client, 1).await;
        let public_key = public_keys.first().unwrap().clone();

        let mut settings = RepublisherSettings::default();
        settings
            .pkarr_client(pkarr_client)
            .min_sufficient_node_publish_count(NonZeroU8::new(4).unwrap());
        let publisher = MultiRepublisher::new_with_settings(settings, Some(pkarr_builder));
        let results = publisher.run_serially(public_keys).await.unwrap();
        let result = results.get(&public_key).unwrap();
        assert!(result.is_err());
    }

This test used to work before pkarr and mainline were upgraded in #315 .

There are two ways this test can be made to work:

  • by using Testnet::new_unseeded(3) in the first line, to instantiate the dht
  • by bumping the argument of min_sufficient_node_publish_count to 5
    • since the test expects an err, the fact a 5 here succeeds and 4 fails hints at the fact that the test published to 4 nodes

Both suggest that Testnet::new(n), which internally uses Testnet::build_seeded, actually spins up 4 nodes.

Please investigate and re-align the behavior of Testnet::new(n) with Testnet::new_unseeded(n) in terms of created nodes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions