fix unit and integration tests
This commit is contained in:
parent
a8487ffef1
commit
16c96bd8c0
|
@ -47,8 +47,9 @@ suite "Test BackendFactory":
|
||||||
let
|
let
|
||||||
config = CodexConf(
|
config = CodexConf(
|
||||||
cmd: StartUpCmd.persistence,
|
cmd: StartUpCmd.persistence,
|
||||||
nat: ValidIpAddress.init("127.0.0.1"),
|
nat: NatConfig(
|
||||||
discoveryIp: ValidIpAddress.init(IPv4_any()),
|
hasExtIp: false,
|
||||||
|
nat: NatNone),
|
||||||
metricsAddress: ValidIpAddress.init("127.0.0.1"),
|
metricsAddress: ValidIpAddress.init("127.0.0.1"),
|
||||||
persistenceCmd: PersistenceCmd.prover,
|
persistenceCmd: PersistenceCmd.prover,
|
||||||
marketplaceAddress: EthAddress.example.some,
|
marketplaceAddress: EthAddress.example.some,
|
||||||
|
@ -68,8 +69,9 @@ suite "Test BackendFactory":
|
||||||
let
|
let
|
||||||
config = CodexConf(
|
config = CodexConf(
|
||||||
cmd: StartUpCmd.persistence,
|
cmd: StartUpCmd.persistence,
|
||||||
nat: ValidIpAddress.init("127.0.0.1"),
|
nat: NatConfig(
|
||||||
discoveryIp: ValidIpAddress.init(IPv4_any()),
|
hasExtIp: false,
|
||||||
|
nat: NatNone),
|
||||||
metricsAddress: ValidIpAddress.init("127.0.0.1"),
|
metricsAddress: ValidIpAddress.init("127.0.0.1"),
|
||||||
persistenceCmd: PersistenceCmd.prover,
|
persistenceCmd: PersistenceCmd.prover,
|
||||||
marketplaceAddress: EthAddress.example.some,
|
marketplaceAddress: EthAddress.example.some,
|
||||||
|
@ -90,8 +92,9 @@ suite "Test BackendFactory":
|
||||||
let
|
let
|
||||||
config = CodexConf(
|
config = CodexConf(
|
||||||
cmd: StartUpCmd.persistence,
|
cmd: StartUpCmd.persistence,
|
||||||
nat: ValidIpAddress.init("127.0.0.1"),
|
nat: NatConfig(
|
||||||
discoveryIp: ValidIpAddress.init(IPv4_any()),
|
hasExtIp: false,
|
||||||
|
nat: NatNone),
|
||||||
metricsAddress: ValidIpAddress.init("127.0.0.1"),
|
metricsAddress: ValidIpAddress.init("127.0.0.1"),
|
||||||
persistenceCmd: PersistenceCmd.prover,
|
persistenceCmd: PersistenceCmd.prover,
|
||||||
marketplaceAddress: EthAddress.example.some,
|
marketplaceAddress: EthAddress.example.some,
|
||||||
|
|
|
@ -19,7 +19,7 @@ import pkg/codex/conf
|
||||||
import pkg/confutils/defs
|
import pkg/confutils/defs
|
||||||
import pkg/poseidon2/io
|
import pkg/poseidon2/io
|
||||||
import pkg/codex/utils/poseidon2digest
|
import pkg/codex/utils/poseidon2digest
|
||||||
|
import pkg/codex/nat
|
||||||
import ./helpers
|
import ./helpers
|
||||||
import ../helpers
|
import ../helpers
|
||||||
import ./backends/helpers
|
import ./backends/helpers
|
||||||
|
@ -43,8 +43,9 @@ suite "Test Prover":
|
||||||
metaDs = metaTmp.newDb()
|
metaDs = metaTmp.newDb()
|
||||||
config = CodexConf(
|
config = CodexConf(
|
||||||
cmd: StartUpCmd.persistence,
|
cmd: StartUpCmd.persistence,
|
||||||
nat: ValidIpAddress.init("127.0.0.1"),
|
nat: NatConfig(
|
||||||
discoveryIp: ValidIpAddress.init(IPv4_any()),
|
hasExtIp: false,
|
||||||
|
nat: NatNone),
|
||||||
metricsAddress: ValidIpAddress.init("127.0.0.1"),
|
metricsAddress: ValidIpAddress.init("127.0.0.1"),
|
||||||
persistenceCmd: PersistenceCmd.prover,
|
persistenceCmd: PersistenceCmd.prover,
|
||||||
circomR1cs: InputFile("tests/circuits/fixtures/proof_main.r1cs"),
|
circomR1cs: InputFile("tests/circuits/fixtures/proof_main.r1cs"),
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
import std/[unittest, options, net],stew/shims/net as stewNet
|
||||||
|
import pkg/chronos
|
||||||
|
import pkg/libp2p/[multiaddress, multihash, multicodec]
|
||||||
|
import pkg/stew/results
|
||||||
|
|
||||||
|
import ../../codex/nat
|
||||||
|
import ../../codex/utils/natutils
|
||||||
|
import ../../codex/utils
|
||||||
|
|
||||||
|
|
||||||
|
suite "NAT Address Tests":
|
||||||
|
test "natedAddress with local addresses":
|
||||||
|
# Setup test data
|
||||||
|
let
|
||||||
|
udpPort = Port(1234)
|
||||||
|
natConfig = NatConfig(
|
||||||
|
hasExtIp: true,
|
||||||
|
extIp:ValidIpAddress.init("8.8.8.8"))
|
||||||
|
|
||||||
|
# Create test addresses
|
||||||
|
localAddr = MultiAddress.init("/ip4/127.0.0.1/tcp/5000").expect("valid multiaddr")
|
||||||
|
anyAddr = MultiAddress.init("/ip4/0.0.0.0/tcp/5000").expect("valid multiaddr")
|
||||||
|
publicAddr = MultiAddress.init("/ip4/192.168.1.1/tcp/5000").expect("valid multiaddr")
|
||||||
|
|
||||||
|
# Expected results
|
||||||
|
let
|
||||||
|
expectedDiscoveryAddrs = @[
|
||||||
|
MultiAddress.init("/ip4/8.8.8.8/udp/1234").expect("valid multiaddr"),
|
||||||
|
MultiAddress.init("/ip4/8.8.8.8/udp/1234").expect("valid multiaddr"),
|
||||||
|
MultiAddress.init("/ip4/8.8.8.8/udp/1234").expect("valid multiaddr")
|
||||||
|
]
|
||||||
|
expectedlibp2pAddrs = @[
|
||||||
|
MultiAddress.init("/ip4/8.8.8.8/tcp/5000").expect("valid multiaddr"),
|
||||||
|
MultiAddress.init("/ip4/8.8.8.8/tcp/5000").expect("valid multiaddr"),
|
||||||
|
MultiAddress.init("/ip4/8.8.8.8/tcp/5000").expect("valid multiaddr")
|
||||||
|
]
|
||||||
|
|
||||||
|
#ipv6Addr = MultiAddress.init("/ip6/::1/tcp/5000").expect("valid multiaddr")
|
||||||
|
addrs = @[localAddr, anyAddr, publicAddr]
|
||||||
|
|
||||||
|
# Test address remapping
|
||||||
|
let (libp2pAddrs,discoveryAddrs) = natedAddress(natConfig, addrs, udpPort)
|
||||||
|
|
||||||
|
# Verify results
|
||||||
|
check(discoveryAddrs == expectedDiscoveryAddrs)
|
||||||
|
check(libp2pAddrs == expectedlibp2pAddrs)
|
|
@ -15,15 +15,17 @@ method getChainId*(provider: MockProvider): Future[UInt256] {.async: (raises:[Pr
|
||||||
proc configFactory(): CodexConf =
|
proc configFactory(): CodexConf =
|
||||||
CodexConf(
|
CodexConf(
|
||||||
cmd: StartUpCmd.persistence,
|
cmd: StartUpCmd.persistence,
|
||||||
nat: ValidIpAddress.init("127.0.0.1"),
|
nat: NatConfig(
|
||||||
discoveryIp: ValidIpAddress.init(IPv4_any()),
|
hasExtIp: false,
|
||||||
|
nat: NatNone),
|
||||||
metricsAddress: ValidIpAddress.init("127.0.0.1"))
|
metricsAddress: ValidIpAddress.init("127.0.0.1"))
|
||||||
|
|
||||||
proc configFactory(marketplace: Option[EthAddress]): CodexConf =
|
proc configFactory(marketplace: Option[EthAddress]): CodexConf =
|
||||||
CodexConf(
|
CodexConf(
|
||||||
cmd: StartUpCmd.persistence,
|
cmd: StartUpCmd.persistence,
|
||||||
nat: ValidIpAddress.init("127.0.0.1"),
|
nat: NatConfig(
|
||||||
discoveryIp: ValidIpAddress.init(IPv4_any()),
|
hasExtIp: false,
|
||||||
|
nat: NatNone),
|
||||||
metricsAddress: ValidIpAddress.init("127.0.0.1"),
|
metricsAddress: ValidIpAddress.init("127.0.0.1"),
|
||||||
marketplaceAddress: marketplace)
|
marketplaceAddress: marketplace)
|
||||||
|
|
||||||
|
|
|
@ -166,9 +166,8 @@ template multinodesuite*(name: string, body: untyped) =
|
||||||
config.addCliOption("--bootstrap-node", bootstrapNode)
|
config.addCliOption("--bootstrap-node", bootstrapNode)
|
||||||
config.addCliOption("--api-port", $ await nextFreePort(8080 + nodeIdx))
|
config.addCliOption("--api-port", $ await nextFreePort(8080 + nodeIdx))
|
||||||
config.addCliOption("--data-dir", datadir)
|
config.addCliOption("--data-dir", datadir)
|
||||||
config.addCliOption("--nat", "127.0.0.1")
|
config.addCliOption("--nat", "none")
|
||||||
config.addCliOption("--listen-addrs", "/ip4/127.0.0.1/tcp/0")
|
config.addCliOption("--listen-addrs", "/ip4/127.0.0.1/tcp/0")
|
||||||
config.addCliOption("--disc-ip", "127.0.0.1")
|
|
||||||
config.addCliOption("--disc-port", $ await nextFreePort(8090 + nodeIdx))
|
config.addCliOption("--disc-port", $ await nextFreePort(8090 + nodeIdx))
|
||||||
|
|
||||||
except CodexConfigError as e:
|
except CodexConfigError as e:
|
||||||
|
|
|
@ -27,9 +27,8 @@ ethersuite "Node block expiration tests":
|
||||||
node = await CodexProcess.startNode(@[
|
node = await CodexProcess.startNode(@[
|
||||||
"--api-port=8080",
|
"--api-port=8080",
|
||||||
"--data-dir=" & dataDir,
|
"--data-dir=" & dataDir,
|
||||||
"--nat=127.0.0.1",
|
"--nat=none",
|
||||||
"--listen-addrs=/ip4/127.0.0.1/tcp/0",
|
"--listen-addrs=/ip4/127.0.0.1/tcp/0",
|
||||||
"--disc-ip=127.0.0.1",
|
|
||||||
"--disc-port=8090",
|
"--disc-port=8090",
|
||||||
"--block-ttl=" & $blockTtlSeconds,
|
"--block-ttl=" & $blockTtlSeconds,
|
||||||
"--block-mi=1",
|
"--block-mi=1",
|
||||||
|
|
|
@ -21,8 +21,7 @@ suite "Taiko L2 Integration Tests":
|
||||||
node1 = startNode([
|
node1 = startNode([
|
||||||
"--data-dir=" & createTempDir("", ""),
|
"--data-dir=" & createTempDir("", ""),
|
||||||
"--api-port=8080",
|
"--api-port=8080",
|
||||||
"--nat=127.0.0.1",
|
"--nat=none",
|
||||||
"--disc-ip=127.0.0.1",
|
|
||||||
"--disc-port=8090",
|
"--disc-port=8090",
|
||||||
"--persistence",
|
"--persistence",
|
||||||
"--eth-provider=https://rpc.test.taiko.xyz"
|
"--eth-provider=https://rpc.test.taiko.xyz"
|
||||||
|
@ -34,8 +33,7 @@ suite "Taiko L2 Integration Tests":
|
||||||
node2 = startNode([
|
node2 = startNode([
|
||||||
"--data-dir=" & createTempDir("", ""),
|
"--data-dir=" & createTempDir("", ""),
|
||||||
"--api-port=8081",
|
"--api-port=8081",
|
||||||
"--nat=127.0.0.1",
|
"--nat=none",
|
||||||
"--disc-ip=127.0.0.1",
|
|
||||||
"--disc-port=8091",
|
"--disc-port=8091",
|
||||||
"--bootstrap-node=" & bootstrap,
|
"--bootstrap-node=" & bootstrap,
|
||||||
"--persistence",
|
"--persistence",
|
||||||
|
|
Loading…
Reference in New Issue