Implement rpc server by Aritra8438 · Pull Request #222 · braidpool/braidpool · GitHub
Skip to content
Closed
1 change: 1 addition & 0 deletions node/Cargo.toml
6 changes: 4 additions & 2 deletions node/src/bead/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ use bitcoin::consensus::encode::Encodable;
use bitcoin::consensus::Error;
use bitcoin::io::{self, BufRead, Write};
use bitcoin::BlockHeader;
use libp2p::futures::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
use futures::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
use libp2p::request_response::Codec;
use libp2p::StreamProtocol;
use serde::Deserialize;
use serde::Serialize;
use std::collections::HashSet;

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Bead {
pub block_header: BlockHeader,
pub committed_metadata: CommittedMetadata,
Expand Down
15 changes: 6 additions & 9 deletions node/src/bead/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,18 @@ fn test_serialized_committed_metadata() {
let public_key = "020202020202020202020202020202020202020202020202020202020202020202"
.parse::<bitcoin::PublicKey>()
.unwrap();
let socket = bitcoin::p2p::address::AddrV2::Ipv4(Ipv4Addr::new(127, 0, 0, 1));
let time_val = Time::from_consensus(1653195600).unwrap();
let parent_hash_set: HashSet<BlockHash> = HashSet::new();
let time_hash_set = TimeVec(Vec::new());
let weak_target = CompactTarget::from_consensus(32);
let min_target = CompactTarget::from_consensus(1);
let test_committed_metadata = TestCommittedMetadataBuilder::new()
.comm_pub_key(public_key)
.miner_ip(socket)
.miner_ip(String::from("127.0.0.1"))
.start_timestamp(time_val)
.parents(parent_hash_set)
.parent_bead_timestamps(time_hash_set)
.payout_address(_address)
.payout_address(String::from("127.0.0.1:8888"))
.transactions(vec![])
.min_target(min_target)
.weak_target(weak_target)
Expand Down Expand Up @@ -107,19 +106,18 @@ fn test_serialized_bead() {
let public_key = "020202020202020202020202020202020202020202020202020202020202020202"
.parse::<bitcoin::PublicKey>()
.unwrap();
let socket = bitcoin::p2p::address::AddrV2::Ipv4(Ipv4Addr::new(127, 0, 0, 1));
let time_hash_set = TimeVec(Vec::new());
let parent_hash_set: HashSet<BlockHash> = HashSet::new();
let weak_target = CompactTarget::from_consensus(32);
let min_target = CompactTarget::from_consensus(1);
let time_val = Time::from_consensus(1653195600).unwrap();
let test_committed_metadata = TestCommittedMetadataBuilder::new()
.comm_pub_key(public_key)
.miner_ip(socket)
.miner_ip(String::from("127.0.0.1"))
.start_timestamp(time_val)
.parents(parent_hash_set)
.parent_bead_timestamps(time_hash_set)
.payout_address(_address)
.payout_address(String::from("127.0.0.1:8888"))
.min_target(min_target)
.weak_target(weak_target)
.transactions(vec![])
Expand Down Expand Up @@ -182,19 +180,18 @@ fn test_bead_response_serialization() {
let public_key = "020202020202020202020202020202020202020202020202020202020202020202"
.parse::<bitcoin::PublicKey>()
.unwrap();
let socket = bitcoin::p2p::address::AddrV2::Ipv4(Ipv4Addr::new(127, 0, 0, 1));
let time_hash_set = TimeVec(Vec::new());
let parent_hash_set: HashSet<BlockHash> = HashSet::new();
let weak_target = CompactTarget::from_consensus(32);
let min_target = CompactTarget::from_consensus(1);
let time_val = Time::from_consensus(1653195600).unwrap();
let test_committed_metadata = TestCommittedMetadataBuilder::new()
.comm_pub_key(public_key)
.miner_ip(socket)
.miner_ip(String::from("127.0.0.1"))
.start_timestamp(time_val)
.parents(parent_hash_set)
.parent_bead_timestamps(time_hash_set)
.payout_address(_address)
.payout_address(String::from("127.0.0.1:8888"))
.min_target(min_target)
.weak_target(weak_target)
.transactions(vec![])
Expand Down
5 changes: 2 additions & 3 deletions node/src/behaviour/tests.rs
Loading
Loading