Fix setup_chains to use state block instead of legacy blocks. (#4188)
Fix issue where functions were not using the specified source account and were directly using the dev genesis account.
This commit is contained in:
		
					parent
					
						
							
								e8ddd831db
							
						
					
				
			
			
				commit
				
					
						6c10b9f705
					
				
			
		
					 2 changed files with 31 additions and 21 deletions
				
			
		| 
						 | 
					@ -15,10 +15,12 @@ nano::block_list_t nano::test::setup_chain (nano::test::system & system, nano::n
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		balance -= 1;
 | 
							balance -= 1;
 | 
				
			||||||
		auto send = builder
 | 
							auto send = builder
 | 
				
			||||||
					.send ()
 | 
										.state ()
 | 
				
			||||||
 | 
										.account (target.pub)
 | 
				
			||||||
					.previous (latest)
 | 
										.previous (latest)
 | 
				
			||||||
					.destination (throwaway.pub)
 | 
										.representative (throwaway.pub)
 | 
				
			||||||
					.balance (balance)
 | 
										.balance (balance)
 | 
				
			||||||
 | 
										.link (throwaway.pub)
 | 
				
			||||||
					.sign (target.prv, target.pub)
 | 
										.sign (target.prv, target.pub)
 | 
				
			||||||
					.work (*system.work.generate (latest))
 | 
										.work (*system.work.generate (latest))
 | 
				
			||||||
					.build_shared ();
 | 
										.build_shared ();
 | 
				
			||||||
| 
						 | 
					@ -53,19 +55,23 @@ std::vector<std::pair<nano::account, nano::block_list_t>> nano::test::setup_chai
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		balance -= block_count * 2; // Send enough to later create `block_count` blocks
 | 
							balance -= block_count * 2; // Send enough to later create `block_count` blocks
 | 
				
			||||||
		auto send = builder
 | 
							auto send = builder
 | 
				
			||||||
					.send ()
 | 
										.state ()
 | 
				
			||||||
 | 
										.account (source.pub)
 | 
				
			||||||
					.previous (latest)
 | 
										.previous (latest)
 | 
				
			||||||
					.destination (key.pub)
 | 
										.representative (source.pub)
 | 
				
			||||||
					.balance (balance)
 | 
										.balance (balance)
 | 
				
			||||||
					.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
 | 
										.link (key.pub)
 | 
				
			||||||
 | 
										.sign (source.prv, source.pub)
 | 
				
			||||||
					.work (*system.work.generate (latest))
 | 
										.work (*system.work.generate (latest))
 | 
				
			||||||
					.build_shared ();
 | 
										.build_shared ();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		auto open = builder
 | 
							auto open = builder
 | 
				
			||||||
					.open ()
 | 
										.state ()
 | 
				
			||||||
					.source (send->hash ())
 | 
					 | 
				
			||||||
					.representative (key.pub)
 | 
					 | 
				
			||||||
					.account (key.pub)
 | 
										.account (key.pub)
 | 
				
			||||||
 | 
										.previous (0)
 | 
				
			||||||
 | 
										.representative (key.pub)
 | 
				
			||||||
 | 
										.balance (block_count * 2)
 | 
				
			||||||
 | 
										.link (send->hash ())
 | 
				
			||||||
					.sign (key.prv, key.pub)
 | 
										.sign (key.prv, key.pub)
 | 
				
			||||||
					.work (*system.work.generate (key.pub))
 | 
										.work (*system.work.generate (key.pub))
 | 
				
			||||||
					.build_shared ();
 | 
										.build_shared ();
 | 
				
			||||||
| 
						 | 
					@ -107,12 +113,12 @@ nano::block_list_t nano::test::setup_independent_blocks (nano::test::system & sy
 | 
				
			||||||
		balance -= 1;
 | 
							balance -= 1;
 | 
				
			||||||
		auto send = builder
 | 
							auto send = builder
 | 
				
			||||||
					.state ()
 | 
										.state ()
 | 
				
			||||||
					.account (nano::dev::genesis_key.pub)
 | 
										.account (source.pub)
 | 
				
			||||||
					.previous (latest)
 | 
										.previous (latest)
 | 
				
			||||||
					.representative (nano::dev::genesis_key.pub)
 | 
										.representative (source.pub)
 | 
				
			||||||
					.balance (balance)
 | 
										.balance (balance)
 | 
				
			||||||
					.link (key.pub)
 | 
										.link (key.pub)
 | 
				
			||||||
					.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
 | 
										.sign (source.prv, source.pub)
 | 
				
			||||||
					.work (*system.work.generate (latest))
 | 
										.work (*system.work.generate (latest))
 | 
				
			||||||
					.build_shared ();
 | 
										.build_shared ();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -151,19 +157,23 @@ nano::keypair nano::test::setup_rep (nano::test::system & system, nano::node & n
 | 
				
			||||||
	nano::block_builder builder;
 | 
						nano::block_builder builder;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto send = builder
 | 
						auto send = builder
 | 
				
			||||||
				.send ()
 | 
									.state ()
 | 
				
			||||||
 | 
									.account (source.pub)
 | 
				
			||||||
				.previous (latest)
 | 
									.previous (latest)
 | 
				
			||||||
				.destination (key.pub)
 | 
									.representative (source.pub)
 | 
				
			||||||
				.balance (balance - amount)
 | 
									.balance (balance - amount)
 | 
				
			||||||
				.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
 | 
									.link (key.pub)
 | 
				
			||||||
 | 
									.sign (source.prv, source.pub)
 | 
				
			||||||
				.work (*system.work.generate (latest))
 | 
									.work (*system.work.generate (latest))
 | 
				
			||||||
				.build_shared ();
 | 
									.build_shared ();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto open = builder
 | 
						auto open = builder
 | 
				
			||||||
				.open ()
 | 
									.state ()
 | 
				
			||||||
				.source (send->hash ())
 | 
					 | 
				
			||||||
				.representative (key.pub)
 | 
					 | 
				
			||||||
				.account (key.pub)
 | 
									.account (key.pub)
 | 
				
			||||||
 | 
									.previous (0)
 | 
				
			||||||
 | 
									.representative (key.pub)
 | 
				
			||||||
 | 
									.balance (amount)
 | 
				
			||||||
 | 
									.link (send->hash ())
 | 
				
			||||||
				.sign (key.prv, key.pub)
 | 
									.sign (key.prv, key.pub)
 | 
				
			||||||
				.work (*system.work.generate (key.pub))
 | 
									.work (*system.work.generate (key.pub))
 | 
				
			||||||
				.build_shared ();
 | 
									.build_shared ();
 | 
				
			||||||
| 
						 | 
					@ -173,4 +183,4 @@ nano::keypair nano::test::setup_rep (nano::test::system & system, nano::node & n
 | 
				
			||||||
	EXPECT_TIMELY (5s, nano::test::confirmed (node, { send, open }));
 | 
						EXPECT_TIMELY (5s, nano::test::confirmed (node, { send, open }));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return key;
 | 
						return key;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,10 +14,10 @@
 | 
				
			||||||
namespace nano::test
 | 
					namespace nano::test
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Creates `count` random 1 raw send blocks in a `target` account chain
 | 
					 * Creates `count` random 1 raw send blocks in a `source` account chain
 | 
				
			||||||
 * @returns created blocks
 | 
					 * @returns created blocks
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
nano::block_list_t setup_chain (nano::test::system & system, nano::node & node, int count, nano::keypair target = nano::dev::genesis_key, bool confirm = true);
 | 
					nano::block_list_t setup_chain (nano::test::system & system, nano::node & node, int count, nano::keypair source = nano::dev::genesis_key, bool confirm = true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Creates `chain_count` account chains, each with `block_count` 1 raw random send blocks, all accounts are seeded from `source` account
 | 
					 * Creates `chain_count` account chains, each with `block_count` 1 raw random send blocks, all accounts are seeded from `source` account
 | 
				
			||||||
| 
						 | 
					@ -37,4 +37,4 @@ nano::block_list_t setup_independent_blocks (nano::test::system & system, nano::
 | 
				
			||||||
 * @return created representative
 | 
					 * @return created representative
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
nano::keypair setup_rep (nano::test::system & system, nano::node & node, nano::uint128_t amount, nano::keypair source = nano::dev::genesis_key);
 | 
					nano::keypair setup_rep (nano::test::system & system, nano::node & node, nano::uint128_t amount, nano::keypair source = nano::dev::genesis_key);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue