From 9df360cf63bb4dd9d39d2d7c5e3348b33744aac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Wed, 23 Jun 2021 16:08:27 +0100 Subject: [PATCH] Removed constructors only used in tests To elaborate further, to update Mixnode constructor it would require adding yet two more arguments and at that point the compiler warns about too many arguments --- common/mixnet-contract/src/gateway.rs | 22 -------- common/mixnet-contract/src/mixnode.rs | 22 -------- contracts/mixnet/src/support/tests.rs | 77 ++++++++++++++------------- 3 files changed, 41 insertions(+), 80 deletions(-) diff --git a/common/mixnet-contract/src/gateway.rs b/common/mixnet-contract/src/gateway.rs index c474d20a41..3c8d3c0a9a 100644 --- a/common/mixnet-contract/src/gateway.rs +++ b/common/mixnet-contract/src/gateway.rs @@ -19,28 +19,6 @@ pub struct Gateway { pub version: String, } -impl Gateway { - pub fn new( - host: String, - mix_port: u16, - clients_port: u16, - location: String, - sphinx_key: SphinxKey, - identity_key: IdentityKey, - version: String, - ) -> Self { - Gateway { - host, - mix_port, - clients_port, - location, - sphinx_key, - identity_key, - version, - } - } -} - #[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)] pub struct GatewayBond { pub amount: Vec, diff --git a/common/mixnet-contract/src/mixnode.rs b/common/mixnet-contract/src/mixnode.rs index d5fb1f8f3b..8ceb5c26fa 100644 --- a/common/mixnet-contract/src/mixnode.rs +++ b/common/mixnet-contract/src/mixnode.rs @@ -21,28 +21,6 @@ pub struct MixNode { pub version: String, } -impl MixNode { - pub fn new( - host: String, - mix_port: u16, - layer: u64, - location: String, - sphinx_key: SphinxKey, - identity_key: IdentityKey, - version: String, - ) -> Self { - MixNode { - host, - mix_port, - layer, - location, - sphinx_key, - identity_key, - version, - } - } -} - #[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)] pub struct MixNodeBond { // TODO: diff --git a/contracts/mixnet/src/support/tests.rs b/contracts/mixnet/src/support/tests.rs index 8b3ee0dc37..c591b768a7 100644 --- a/contracts/mixnet/src/support/tests.rs +++ b/contracts/mixnet/src/support/tests.rs @@ -105,52 +105,57 @@ pub mod helpers { } pub fn mix_node_fixture() -> MixNode { - MixNode::new( - "mix.node.org".to_string(), - 1789, - 1, - "Sweden".to_string(), - "sphinx".to_string(), - "identity".to_string(), - "0.10.0".to_string(), - ) + MixNode { + host: "mix.node.org".to_string(), + mix_port: 1789, + verloc_port: 1790, + http_api_port: 8000, + layer: 1, + location: "Sweden".to_string(), + sphinx_key: "sphinx".to_string(), + identity_key: "identity".to_string(), + version: "0.10.0".to_string(), + } } pub fn mixnode_bond_fixture() -> MixNodeBond { - let mix_node = MixNode::new( - "1.1.1.1".to_string(), - 1789, - 1, - "London".to_string(), - "1234".to_string(), - "aaaa".to_string(), - "0.10.0".to_string(), - ); + let mix_node = MixNode { + host: "1.1.1.1".to_string(), + mix_port: 1789, + verloc_port: 1790, + http_api_port: 8000, + layer: 1, + location: "London".to_string(), + sphinx_key: "1234".to_string(), + identity_key: "aaaa".to_string(), + version: "0.10.0".to_string(), + }; MixNodeBond::new(coins(50, DENOM), Addr::unchecked("foo"), mix_node) } pub fn gateway_fixture() -> Gateway { - Gateway::new( - "1.1.1.1".to_string(), - 1789, - 9000, - "Sweden".to_string(), - "sphinx".to_string(), - "identity".to_string(), - "0.10.0".to_string(), - ) + Gateway { + host: "1.1.1.1".to_string(), + mix_port: 1789, + clients_port: 9000, + location: "Sweden".to_string(), + + sphinx_key: "sphinx".to_string(), + identity_key: "identity".to_string(), + version: "0.10.0".to_string(), + } } pub fn gateway_bond_fixture() -> GatewayBond { - let gateway = Gateway::new( - "1.1.1.1".to_string(), - 1789, - 9000, - "London".to_string(), - "sphinx".to_string(), - "identity".to_string(), - "0.10.0".to_string(), - ); + let gateway = Gateway { + host: "1.1.1.1".to_string(), + mix_port: 1789, + clients_port: 9000, + location: "London".to_string(), + sphinx_key: "sphinx".to_string(), + identity_key: "identity".to_string(), + version: "0.10.0".to_string(), + }; GatewayBond::new(coins(50, DENOM), Addr::unchecked("foo"), gateway) }