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

Add a black box local cluster harness #3028

Merged
merged 7 commits into from
Mar 1, 2019

Conversation

aeyakovenko
Copy link
Member

Problem

Multinode tests are not true integration tests. Changing an implementation detail without actually breaking functionality breaks tests that verify cluster functionality. The tests are huge, and a painful to maintain.

Summary of Changes

Add a harness to write tests against the public interface to the network.

Our code base should contain 2 kinds of tests

  • Pure unit tests - These tests cover the implementation details of the function. If the implementation details change, these tests can be deleted and new ones added if necessary. There is no backwards compatibility requirement for unit tests.

  • Pure integration tests - They start form a cluster entry point, and a keypair with some funds. These tests cover network functionality against the public interfaces available on the network. The tests are written in such a way that they can run against a public testnet or a local cluster. Just like unit tests, they check 1 thing at a time against the network.

Not every feature needs an integration test. Especially things that are not fully baked. But all code needs unit tests.

Fixes #

@codecov
Copy link

codecov bot commented Mar 1, 2019

Codecov Report

Merging #3028 into master will increase coverage by 0.4%.
The diff coverage is 54.7%.

@@           Coverage Diff            @@
##           master   #3028     +/-   ##
========================================
+ Coverage    76.8%   77.3%   +0.4%     
========================================
  Files         130     131      +1     
  Lines       20039   19892    -147     
========================================
- Hits        15404   15377     -27     
+ Misses       4635    4515    -120

@garious
Copy link
Contributor

garious commented Mar 1, 2019

Can you put a hypothetical Greg hat on for a minute with focus on naming and consistentcy? I'll review after your next commit.

use solana_sdk::system_transaction::SystemTransaction;

/// Spend and verify from every node in the network
pub fn spend_and_verify_all_nodes(entry: &ContactInfo, alice: &Keypair, nodes: usize) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you remove the converge() call and move the remaining function into client.rs? Maybe a converge_and_verify function would be helpful too, but that would-be 2-liner probably doesn't need a whole module to itself. Maybe put it in tests/local_cluster.rs?

Copy link
Member Author

Choose a reason for hiding this comment

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

@garious the entry point needs to discover the network. maybe rename converge to discover?

src/cluster_tests.rs Outdated Show resolved Hide resolved
src/cluster_tests.rs Outdated Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
use std::thread::JoinHandle;

pub struct LocalCluster {
pub mint: Keypair,
Copy link
Contributor

Choose a reason for hiding this comment

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

mint_keypair

Copy link
Member Author

Choose a reason for hiding this comment

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

@garious funding_keypair? This keypair is intended for the consumer of the LocalCluster to enter the network

src/local_cluster.rs Outdated Show resolved Hide resolved
src/local_cluster.rs Outdated Show resolved Hide resolved
src/local_cluster.rs Outdated Show resolved Hide resolved
src/local_cluster.rs Outdated Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
@garious
Copy link
Contributor

garious commented Mar 1, 2019

Biggest naming nit here is the mix of the term "cluster" and "network" in the same module. Looks like every use of "network" can either be "cluster" or deleted.

src/local_cluster.rs Outdated Show resolved Hide resolved
@aeyakovenko aeyakovenko merged commit c27726e into solana-labs:master Mar 1, 2019
ledger_paths.push(ledger_path.clone());

// Send each validator some tokens to vote
let validator_balance = Self::transfer(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's not creating the vote accounts for the validators. Now the balance of vote account is used to calculate node stakes (for leader rotations etc).

Copy link
Member Author

Choose a reason for hiding this comment

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

@pgarg66 can you show me?

Copy link
Contributor

Choose a reason for hiding this comment

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

This function (or something similar) needs to be called here for every validator node

https://github.com/solana-labs/solana/blob/master/fullnode/src/main.rs#L51

Copy link
Contributor

Choose a reason for hiding this comment

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

This PR changes the way stakes are calculated #2992
Earlier it was using node's account balance. Now it's using staking (voting) account balance.

Copy link
Member Author

Choose a reason for hiding this comment

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

@pgarg66 cool! can you add it?

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

yihau pushed a commit to yihau/solana that referenced this pull request Nov 19, 2024
* extract epoch-info crate

* Update description

Co-authored-by: Joe C <[email protected]>

---------

Co-authored-by: Joe C <[email protected]>
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