btcs

bitcoin script parser/evaluator/compiler/decompiler
git clone git://jb55.com/btcs
Log | Files | Refs | README | LICENSE

commit 0ea47a971c82e357eef307893d80f2bd00f6f2cc
parent c1e377a0b828d51dc1fca298f6052722dee3a665
Author: William Casarin <jb55@jb55.com>
Date:   Wed, 17 Oct 2018 09:50:58 -0700

fix various issues

Diffstat:
Mmph-opcodes | 8++++----
Mscript.c | 1+
Mtest.c | 6+++---
3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/mph-opcodes b/mph-opcodes @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Easy Perfect Minimal Hashing # By Steve Hanov. Released to the public domain. # @@ -40,7 +40,7 @@ def CreateMinimalPerfectHash( dict ): # Step 2: Sort the buckets and process the ones with the most items first. buckets.sort( key=len, reverse=True ) - for b in xrange( size ): + for b in range( size ): bucket = buckets[b] if len(bucket) <= 1: break @@ -68,10 +68,10 @@ def CreateMinimalPerfectHash( dict ): # placing them into a free slot. Use a negative value of d to indicate # this. freelist = [] - for i in xrange(size): + for i in range(size): if values[i] == None: freelist.append( i ) - for b in xrange( b, size ): + for b in range( b, size ): bucket = buckets[b] if len(bucket) == 0: break slot = freelist.pop() diff --git a/script.c b/script.c @@ -812,4 +812,5 @@ script_serialize(struct stack *stack, u8 *buf, int buflen, int* len) { void script_handle_input(struct stack *stack, const char *str) { + fprintf(stderr, "INPUT %s\n", str); } diff --git a/test.c b/test.c @@ -19,8 +19,8 @@ typedef void (program)(struct stack *script, struct stack *stack,\ static void cmp_data(const u8 *a, const u8 *b, int alen, int blen, const char *msg) { - int i = 0; if (memcmp(a, b, blen) != 0) { + int i = 0; printf("#\n# Failed data cmp test\n# > "); for (i = 0; i < alen; ++i) printf("%02x ", a[i] & 0xff); @@ -97,7 +97,7 @@ TEST(negative_integer) { static u8 buf[6]; int len; u8 in_script[] = { 0x01, 0x82 }; - int res = script_eval(in_script, ARRAY_SIZE(in_script), stack, result); + script_eval(in_script, ARRAY_SIZE(in_script), stack, result); script_serialize(stack, buf, ARRAY_SIZE(buf), &len); cmp_data(buf, in_script, len, ARRAY_SIZE(in_script), "negative 2 serializes ok"); } @@ -107,7 +107,7 @@ TEST(add_negative_two) { int len; static u8 in_script[] = { 0x01, 0x82, 0x01, 0x82, OP_ADD }; static u8 expected_out[] = { 0x01, 0x84 }; - int res = script_eval(in_script, ARRAY_SIZE(in_script), stack, result); + script_eval(in_script, ARRAY_SIZE(in_script), stack, result); script_serialize(stack, buf, ARRAY_SIZE(buf), &len); cmp_data(buf, expected_out, len, ARRAY_SIZE(expected_out), "add negative two twice"); }