forked from JoinMarket-Org/joinmarket
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request JoinMarket-Org#163 from AdamISZ/master
Add travis for testing, testing files in test directory
- Loading branch information
Showing
6 changed files
with
180 additions
and
9 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
language: python | ||
python: | ||
- "2.7_with_system_site_packages" | ||
before_install: | ||
- sudo apt-add-repository ppa:bitcoin/bitcoin -y | ||
- sudo apt-get update -q | ||
- sudo apt-get install --no-install-recommends --no-upgrade -qq bitcoind | ||
- sudo apt-get install -y build-essential | ||
- sudo apt-get install -y automake | ||
install: | ||
- pip install numpy | ||
- pip install pexpect | ||
script: | ||
- git clone git://github.com/jedisct1/libsodium.git | ||
- cd libsodium | ||
- git checkout tags/1.0.3 | ||
- ./autogen.sh | ||
- ./configure | ||
- make check | ||
- sudo make install | ||
- cd .. | ||
#set up joinmarket.cfg | ||
- cp test/regtest_joinmarket.cfg joinmarket.cfg | ||
#E2E encryption (libnacl) tests | ||
- python lib/enc_wrapper.py | ||
#start bitcoin regtest daemon and 101 blocks | ||
- mkdir /home/travis/.bitcoin | ||
- cp test/bitcoin.conf /home/travis/.bitcoin/. | ||
- chmod 600 /home/travis/.bitcoin/bitcoin.conf | ||
- bitcoind -regtest -daemon | ||
- sleep 5 | ||
- bitcoin-cli -regtest setgenerate true 101 | ||
- cd test | ||
- python regtest.py | ||
- python wallet-test.py | ||
branches: | ||
only: | ||
- master |
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,5 @@ | ||
rpcuser=bitcoinrpc | ||
rpcpassword=123456abcdef | ||
walletnotify=/usr/bin/wget -q --spider --timeout=0.5 --tries=1 http://localhost:62612/walletnotify?%s | ||
alertnotify=/usr/bin/wget -q --spider --timeout=0.5 --tries=1 http://localhost:62612/alertnotify?%s | ||
|
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,14 @@ | ||
[BLOCKCHAIN] | ||
blockchain_source = regtest | ||
network = testnet | ||
bitcoin_cli_cmd = bitcoin-cli | ||
notify_port = 62612 | ||
[MESSAGING] | ||
host = chat.freenode.net | ||
channel = joinmarket-pit | ||
port = 6667 | ||
usessl = false | ||
socks5 = false | ||
socks5_host = localhost | ||
socks5_port = 9150 | ||
|
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,103 @@ | ||
import sys | ||
import os, time | ||
data_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) | ||
sys.path.insert(0, os.path.join(data_dir, 'lib')) | ||
import subprocess | ||
import unittest | ||
import common | ||
from blockchaininterface import * | ||
import bitcoin as btc | ||
import binascii | ||
import pexpect | ||
|
||
def interact(process, inputs, expected): | ||
if len(inputs) != len(expected): | ||
raise Exception("Invalid inputs to interact()") | ||
for i, inp in enumerate(inputs): | ||
process.expect(expected[i]) | ||
process.sendline(inp) | ||
|
||
|
||
class TestWalletCreation(unittest.TestCase): | ||
|
||
def test_generate(self): | ||
print 'wallet generation and encryption password tests' | ||
#testing a variety of passwords | ||
self.failUnless(self.run_generate('abc123')) | ||
self.failUnless(self.run_generate('dddddddddddddddddddddddddddddddddddddddddddd')) | ||
#null password is accepted | ||
self.failUnless(self.run_generate('')) | ||
#binary password is accepted; good luck with that! | ||
self.failUnless(self.run_generate('\x01'*10)) | ||
#password with NULL bytes is *not* accepted | ||
self.failIf(self.run_generate('\x00'*10)) | ||
|
||
def run_generate(self, pwd): | ||
try: | ||
test_in = [pwd,pwd,'testwallet.json'] | ||
expected = ['Enter wallet encryption passphrase:', | ||
'Reenter wallet encryption passphrase:', | ||
'Input wallet file name'] | ||
testlog = open('test/testlog-'+pwd, 'wb') | ||
p = pexpect.spawn('python wallet-tool.py generate', logfile=testlog) | ||
interact(p, test_in, expected) | ||
p.expect('saved to') | ||
#time.sleep(2) | ||
p.close() | ||
testlog.close() | ||
#anything to check in the log? | ||
if p.exitstatus != 0: | ||
print 'failed due to exit status: '+str(p.exitstatus) | ||
return False | ||
#check the wallet exists (and contains appropriate json?) | ||
if not os.path.isfile('wallets/testwallet.json'): | ||
print 'failed due to wallet missing' | ||
return False | ||
os.remove('wallets/testwallet.json') | ||
except: | ||
return False | ||
return True | ||
|
||
|
||
class TestWalletRecovery(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.testseed = 'earth gentle mouth circle despite pocket adore student board dress blanket worthless' | ||
|
||
def test_recover(self): | ||
print 'wallet recovery from seed test' | ||
self.failUnless(self.run_recover(self.testseed)) | ||
#try using an invalid word list; can add more variants | ||
wrongseed = 'oops '+self.testseed | ||
self.failIf(self.run_recover(wrongseed)) | ||
|
||
def run_recover(self, seed): | ||
try: | ||
testlog = open('test_recover','wb') | ||
p = pexpect.spawn('python wallet-tool.py recover', logfile = testlog) | ||
expected = ['Input 12 word recovery seed', | ||
'Enter wallet encryption passphrase:', | ||
'Reenter wallet encryption passphrase:', | ||
'Input wallet file name'] | ||
test_in = [seed, 'abc123', 'abc123', 'test_recover_wallet.json'] | ||
interact(p, test_in, expected) | ||
p.expect('saved to') | ||
p.close() | ||
testlog.close() | ||
#anything to check in the log? | ||
if p.exitstatus != 0: | ||
print 'failed due to exit status: '+str(p.exitstatus) | ||
return False | ||
#check the wallet exists (and contains appropriate json? todo) | ||
if not os.path.isfile('wallets/test_recover_wallet.json'): | ||
print 'failed due to wallet missing' | ||
return False | ||
os.remove('wallets/test_recover_wallet.json') | ||
except: | ||
return False | ||
return True | ||
|
||
if __name__ == '__main__': | ||
os.chdir(data_dir) | ||
common.load_program_config() | ||
unittest.main() |