Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit da9d682

Browse files
committedAug 7, 2014
dumbwallet: don't segv when handed a key for setup.
Untested code is buggy code! Fixes: #20 Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent b0a978a commit da9d682

File tree

4 files changed

+27
-23
lines changed

4 files changed

+27
-23
lines changed
 

‎dumbwallet.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,8 @@ static void create_wallet(const char *privkey)
7575
len = i2o_ECPublicKey(priv, &p);
7676
assert(len == sizeof(pubkey));
7777
pubkey_to_addr(&pubkey, &addr);
78-
79-
keystr = key_to_base58(NULL, true, priv, false);
8078
}
79+
keystr = key_to_base58(NULL, true, priv, false);
8180

8281
fd = open("dumbwallet.key", O_WRONLY|O_CREAT|O_EXCL, 0400);
8382
if (fd < 0)

‎test/blackbox/Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ TESTS:=$(ALL:%=check-%)
44
check: $(TESTS)
55

66
check-%:
7-
./$*
7+
$(RM) -r $*-dir
8+
ulimit -c unlimited && mkdir $*-dir && ./$* $*-dir

‎test/blackbox/test-01-sync.sh

+16-20
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,47 @@
22

33
set -em
44

5-
rm -rf test-01-dir
6-
mkdir test-01-dir test-01-dir/p1 test-01-dir/p2
5+
mkdir $1/p1 $1/p2
76

87
NEWBLOCK=100100000800000000000000010002dcf2b3ff756f4c39c16a417e69138d79ce03488dda58e4f53cf640b3a99b91de4e8561afa441badda92600000028000000521f00001201212a5b494784a924f2e0249bf4c268af1d0e000000006d07571dee2e35e1378bc43a8e1388d2fef6b3021cc9924b885d53b2ce390ea86d07571dee2e35e1378bc43a8e1388d2fef6b3021cc9924b885d53b2ce390ea86d07571dee2e35e1378bc43a8e1388d2fef6b3021cc9924b885d53b2ce390ea86d07571dee2e35e1378bc43a8e1388d2fef6b3021cc9924b885d53b2ce390ea83e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e449ee153c4ff3b1d7a7f0901
98

109
# Unpack their blockfiles.
11-
xzcat test-01-blockfile1.xz > test-01-dir/p1/blockfile
12-
xzcat test-01-blockfile2.xz > test-01-dir/p2/blockfile
10+
xzcat test-01-blockfile1.xz > $1/p1/blockfile
11+
xzcat test-01-blockfile2.xz > $1/p2/blockfile
1312

1413
# Make sure they find each other.
15-
touch test-01-dir/addresses
16-
ln -sf ../addresses test-01-dir/p1/addresses
17-
ln -sf ../addresses test-01-dir/p2/addresses
14+
touch $1/addresses
15+
ln -sf ../addresses $1/p1/addresses
16+
ln -sf ../addresses $1/p2/addresses
1817

19-
# Core dumps please!
20-
ulimit -c unlimited
21-
22-
../../pettycoin --seeding --developer-test --pettycoin-dir=test-01-dir/p1 > test-01-dir/p1.log 2>&1 &
23-
../../pettycoin --seeding --developer-test --pettycoin-dir=test-01-dir/p2 > test-01-dir/p2.log 2>&1 &
18+
../../pettycoin --seeding --developer-test --pettycoin-dir=$1/p1 > $1/p1.log 2>&1 &
19+
../../pettycoin --seeding --developer-test --pettycoin-dir=$1/p2 > $1/p2.log 2>&1 &
2420

2521
# They should complete within 1 minute.
2622
END=$(( $(date +%s) + 60 ))
2723

2824
# Wait for startup
2925
while [ $(date +%s) -lt $END ]; do
30-
if ../../pettycoin-query --pettycoin-dir=test-01-dir/p1 help >/dev/null 2>&1 && ../../pettycoin-query --pettycoin-dir=test-01-dir/p2 help >/dev/null 2>&1; then
26+
if ../../pettycoin-query --pettycoin-dir=$1/p1 help >/dev/null 2>&1 && ../../pettycoin-query --pettycoin-dir=$1/p2 help >/dev/null 2>&1; then
3127
break;
3228
fi
3329
sleep 5
3430
done
3531

3632
# Give P1 new block, will trigger P2 to ask.
37-
../../pettycoin-query --pettycoin-dir=test-01-dir/p1 submitblock $NEWBLOCK
33+
../../pettycoin-query --pettycoin-dir=$1/p1 submitblock $NEWBLOCK
3834

3935
while [ $(date +%s) -lt $END ]; do
40-
DEPTH1=`../../pettycoin-query --pettycoin-dir=test-01-dir/p1 getinfo | sed -n 's/.*"height" : \([0-9]\+\) .*num_todos.*/\1/p'`
41-
DEPTH2=`../../pettycoin-query --pettycoin-dir=test-01-dir/p2 getinfo | sed -n 's/.*"height" : \([0-9]\+\) .*num_todos.*/\1/p'`
36+
DEPTH1=`../../pettycoin-query --pettycoin-dir=$1/p1 getinfo | sed -n 's/.*"height" : \([0-9]\+\) .*num_todos.*/\1/p'`
37+
DEPTH2=`../../pettycoin-query --pettycoin-dir=$1/p2 getinfo | sed -n 's/.*"height" : \([0-9]\+\) .*num_todos.*/\1/p'`
4238
if [ "$DEPTH1" = "$DEPTH2" ]; then
43-
../../pettycoin-query --pettycoin-dir=test-01-dir/p1 stop
44-
../../pettycoin-query --pettycoin-dir=test-01-dir/p2 stop
39+
../../pettycoin-query --pettycoin-dir=$1/p1 stop
40+
../../pettycoin-query --pettycoin-dir=$1/p2 stop
4541
exit 0
4642
fi
4743
sleep 5
4844
done
4945
echo Timeout >&2
50-
../../pettycoin-query --pettycoin-dir=test-01-dir/p1 stop
51-
../../pettycoin-query --pettycoin-dir=test-01-dir/p2 stop
46+
../../pettycoin-query --pettycoin-dir=$1/p1 stop
47+
../../pettycoin-query --pettycoin-dir=$1/p2 stop
5248
exit 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#! /bin/sh
2+
3+
set -e
4+
5+
OUT=`../../dumbwallet --pettycoin-dir=$1 setup P-cNkMqSEm5FsNGTPcKUaUjoVA8adAm9tezdAjsAeGfxtxjhps76M8`
6+
# Should give correct address.
7+
echo "$OUT" | grep P-mfWxJ45yp2SFn7UciZyNpvDPSyTBhii6PH > /dev/null
8+

0 commit comments

Comments
 (0)
Please sign in to comment.