-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an example test and finnish the framework
- Loading branch information
1 parent
09225b6
commit 83aa120
Showing
10 changed files
with
139 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ Cargo.lock | |
perf.* | ||
*.svg | ||
config.toml | ||
/builds | ||
/builds | ||
/data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import subprocess | ||
import time | ||
import os | ||
import filecmp | ||
from test_framework.test_framework import TestFramework | ||
|
||
|
||
class TestRestart(TestFramework): | ||
def run_test(self): | ||
""" | ||
Tests if we don't corrupt our data dir between restarts. This would have caught, | ||
the error fixed in #9 | ||
""" | ||
print("Running restart test") | ||
base_testdir = "data/TestRestart/" | ||
self.run_node(base_testdir + "1/") | ||
time.sleep(10) | ||
self.stop_node(0) | ||
self.run_node(base_testdir + "2/") | ||
time.sleep(10) | ||
self.stop_node(0) | ||
assert (filecmp.dircmp(base_testdir + "2/", base_testdir + "1/")) | ||
print("restart test passed!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[ | ||
"", | ||
"00000086d6b2636cb2a392d45edc4ec544a10024d30141c9adf4bfd9de533b53", | ||
"00000032bb881de703dcc968e8258080c7ed4a2933e3a35888fa0b2f75f36029", | ||
"000000e8daac2a2e973ecaab46dc948181c638adecf5ae0fd5d3e13aa14364b0", | ||
"00000194763f1233e40afd5f6eb2e64abd2e5e158a4139198a224f8a7503d47e", | ||
"000003776c984edd753b876f0e70d08450f92dd76a768df03d2c42d1880aea5b", | ||
"000001b62ff822d0b1c68e231670eba2cf8d494075f9616447194b370db6f3da", | ||
"000000b6f018c5b53240616c7868eab7e1338de4200ec25b65a5e1c2f3c57c45", | ||
"000002213230ed813e42076f753f666244db421b3e36a3a3ba31384feb61eba2", | ||
"000001e163d0a8e294c3406a713ba4363f422f1322a1d6ab6de4e54b51e868a8" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,83 @@ | ||
[ | ||
{ | ||
"proof": { | ||
{ | ||
"00000086d6b2636cb2a392d45edc4ec544a10024d30141c9adf4bfd9de533b53": { | ||
"1": { | ||
"proofhashes": [], | ||
"rememberindexes": [], | ||
"targethashes": [], | ||
"targetpreimages": [], | ||
"prooftargets": [] | ||
} | ||
}, | ||
{ | ||
"proof": { | ||
"00000032bb881de703dcc968e8258080c7ed4a2933e3a35888fa0b2f75f36029": { | ||
"1": { | ||
"proofhashes": [], | ||
"rememberindexes": [], | ||
"targethashes": [], | ||
"targetpreimages": [], | ||
"prooftargets": [] | ||
} | ||
}, | ||
{ | ||
"proof": { | ||
"000000e8daac2a2e973ecaab46dc948181c638adecf5ae0fd5d3e13aa14364b0": { | ||
"1": { | ||
"proofhashes": [], | ||
"rememberindexes": [], | ||
"targethashes": [], | ||
"targetpreimages": [], | ||
"prooftargets": [] | ||
} | ||
}, | ||
{ | ||
"proof": { | ||
"00000194763f1233e40afd5f6eb2e64abd2e5e158a4139198a224f8a7503d47e": { | ||
"1": { | ||
"proofhashes": [], | ||
"rememberindexes": [], | ||
"targethashes": [], | ||
"targetpreimages": [], | ||
"prooftargets": [] | ||
} | ||
}, | ||
{ | ||
"proof": { | ||
"000003776c984edd753b876f0e70d08450f92dd76a768df03d2c42d1880aea5b": { | ||
"1": { | ||
"proofhashes": [], | ||
"rememberindexes": [], | ||
"targethashes": [], | ||
"targetpreimages": [], | ||
"prooftargets": [] | ||
} | ||
}, | ||
{ | ||
"proof": { | ||
"000001b62ff822d0b1c68e231670eba2cf8d494075f9616447194b370db6f3da": { | ||
"1": { | ||
"proofhashes": [], | ||
"rememberindexes": [], | ||
"targethashes": [], | ||
"targetpreimages": [], | ||
"prooftargets": [] | ||
} | ||
}, | ||
{ | ||
"proof": { | ||
"000000b6f018c5b53240616c7868eab7e1338de4200ec25b65a5e1c2f3c57c45": { | ||
"1": { | ||
"proofhashes": [], | ||
"rememberindexes": [], | ||
"targethashes": [], | ||
"targetpreimages": [], | ||
"prooftargets": [] | ||
} | ||
}, | ||
{ | ||
"proof": { | ||
"000002213230ed813e42076f753f666244db421b3e36a3a3ba31384feb61eba2": { | ||
"1": { | ||
"proofhashes": [], | ||
"rememberindexes": [], | ||
"targethashes": [], | ||
"targetpreimages": [], | ||
"prooftargets": [] | ||
} | ||
}, | ||
{ | ||
"proof": { | ||
"000001e163d0a8e294c3406a713ba4363f422f1322a1d6ab6de4e54b51e868a8": { | ||
"1": { | ||
"proofhashes": [], | ||
"rememberindexes": [], | ||
"targethashes": [], | ||
"targetpreimages": [], | ||
"prooftargets": [] | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
""" | ||
This is an example of how tests should look lke, see the class bellow for more info | ||
""" | ||
import time | ||
import os | ||
|
||
from test_framework.test_framework import TestFramework | ||
from test_framework.electrum_client import ElectrumClient | ||
from test_framework.mock_rpc import MockUtreexod | ||
|
||
# Tests should be a child class from TestFramework | ||
|
||
|
||
class ExampleTest(TestFramework): | ||
# All tests should override the run_test method | ||
def run_test(self): | ||
# This creates a dummy rpc listening on port 8080 | ||
self.run_rpc() | ||
# Wait until the rpc is ready | ||
time.sleep(1) | ||
# Start a new node (this crate's binary) | ||
node1 = self.run_node("./data/test1", "signet") | ||
# Wait the node to start | ||
time.sleep(10) | ||
# Create an instance of the Electrum Client, a small implementation of the electrum | ||
# protocol, to test our own electrum implementation | ||
electrum = ElectrumClient("localhost", 50001) | ||
print(electrum.get_version()) | ||
|
||
# .... cleanup .... | ||
os.rmdir("./data") | ||
# Stop any rpc server that is running | ||
self.stop_rpc() | ||
# Stop the node that is running | ||
self.stop_node(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters