UnverifiedTransaction type (#4134)
* Introducing ValidSignedTransaction * Verifiying transactions in engines * Widening use of VerifiedSignedTransaction * Renaming Transactions * Uncommenting banning queue & Fixing tests * Fixing json tests * Fixing pre-homestead test * Fixing imports * Addressing grumbles * Fixing test
This commit is contained in:
@@ -364,7 +364,7 @@ impl ChainNotify for EthSync {
|
||||
struct TxRelay(Arc<BlockChainClient>);
|
||||
|
||||
impl LightHandler for TxRelay {
|
||||
fn on_transactions(&self, ctx: &EventContext, relay: &[::ethcore::transaction::SignedTransaction]) {
|
||||
fn on_transactions(&self, ctx: &EventContext, relay: &[::ethcore::transaction::UnverifiedTransaction]) {
|
||||
trace!(target: "les", "Relaying {} transactions from peer {}", relay.len(), ctx.peer());
|
||||
self.0.queue_transactions(relay.iter().map(|tx| ::rlp::encode(tx).to_vec()).collect(), ctx.peer())
|
||||
}
|
||||
|
||||
@@ -2124,7 +2124,7 @@ mod tests {
|
||||
use std::collections::{HashSet, VecDeque};
|
||||
use tests::helpers::*;
|
||||
use tests::snapshot::TestSnapshotService;
|
||||
use util::{U256, RwLock};
|
||||
use util::{U256, Address, RwLock};
|
||||
use util::sha3::Hashable;
|
||||
use util::hash::{H256, FixedHash};
|
||||
use util::bytes::Bytes;
|
||||
@@ -2132,8 +2132,10 @@ mod tests {
|
||||
use super::*;
|
||||
use ::SyncConfig;
|
||||
use super::{PeerInfo, PeerAsking};
|
||||
use ethkey;
|
||||
use ethcore::header::*;
|
||||
use ethcore::client::*;
|
||||
use ethcore::transaction::UnverifiedTransaction;
|
||||
use ethcore::miner::MinerService;
|
||||
|
||||
fn get_dummy_block(order: u32, parent_hash: H256) -> Bytes {
|
||||
@@ -2762,6 +2764,10 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn should_add_transactions_to_queue() {
|
||||
fn sender(tx: &UnverifiedTransaction) -> Address {
|
||||
ethkey::public_to_address(&tx.recover_public().unwrap())
|
||||
}
|
||||
|
||||
// given
|
||||
let mut client = TestBlockChainClient::new();
|
||||
client.add_blocks(98, EachBlockWith::Uncle);
|
||||
@@ -2775,8 +2781,9 @@ mod tests {
|
||||
// Add some balance to clients and reset nonces
|
||||
for h in &[good_blocks[0], retracted_blocks[0]] {
|
||||
let block = client.block(BlockId::Hash(*h)).unwrap();
|
||||
client.set_balance(block.transactions()[0].sender().unwrap(), U256::from(1_000_000_000));
|
||||
client.set_nonce(block.transactions()[0].sender().unwrap(), U256::from(0));
|
||||
let sender = sender(&block.transactions()[0]);;
|
||||
client.set_balance(sender, U256::from(1_000_000_000));
|
||||
client.set_nonce(sender, U256::from(0));
|
||||
}
|
||||
|
||||
|
||||
@@ -2793,7 +2800,7 @@ mod tests {
|
||||
// We need to update nonce status (because we say that the block has been imported)
|
||||
for h in &[good_blocks[0]] {
|
||||
let block = client.block(BlockId::Hash(*h)).unwrap();
|
||||
client.set_nonce(block.transactions()[0].sender().unwrap(), U256::from(1));
|
||||
client.set_nonce(sender(&block.transactions()[0]), U256::from(1));
|
||||
}
|
||||
{
|
||||
let queue = RwLock::new(VecDeque::new());
|
||||
|
||||
Reference in New Issue
Block a user