Commit graph

2255 commits

Author SHA1 Message Date
John C. Vernaleo
86f848ddd4 Convert floats to int64.
Following the example of bitcoind and the bitcoin wiki, provide a
function to convert floats (which are returned by the json-rpc server)
to int64 (which is the normal representation for most values involving
bitcoins).
2013-07-08 17:20:41 -04:00
John C. Vernaleo
39cef5e76a Fix typo in command name getaddressesbyaccount.
Caught by jrick@
2013-07-08 17:12:16 -04:00
Dave Collins
eb5de559ff Fix a couple of comment typos for the word execute. 2013-07-06 11:59:07 -05:00
Owain G. Ainsworth
bedaddb790 add GetScriptClass to return the internal script type of a script.
To be used to tell which class a script is (multisig, scripthash, pubkey,
pkhash, or nonstandard)
2013-07-05 15:23:02 +01:00
Owain G. Ainsworth
4d31b2c850 Remove blurb about 100% coverage and replace with comprehensive.
btcscript contains an amount of debug logging that is very useful to
have. We have agreed that testing this isn't realy practical or indeed
really useful and thus is rather unlikely to grow test coverage any time
soon.
2013-06-28 01:15:10 +01:00
Owain G. Ainsworth
c41330e772 Add basic test for if internal opcode definitions are buggy. 2013-06-28 00:46:34 +01:00
Owain G. Ainsworth
89578c985a add basic test for OP_SHA1
yup, it produces the sha of the data.
2013-06-27 16:15:32 +01:00
Owain G. Ainsworth
e5a2756795 Test empty scripts and out of bounds for DisasmScript()
give disasmscript a defined error return for out of bounds.
2013-06-27 15:07:37 +01:00
Owain G. Ainsworth
244ce4b96e add IsPayToScriptHash api
To tell ifa bytestream matches teh p2sh pattern.
2013-06-27 14:20:08 +01:00
Owain G. Ainsworth
bcd8c9d227 gofmt 2013-06-27 14:20:08 +01:00
Owain G. Ainsworth
dd216cef29 Test pushing at and beyond the boundary for largest stack item. 2013-06-26 23:57:49 +01:00
Owain G. Ainsworth
df898ae1dd test a few non-standards script types to hit some edge cases. 2013-06-26 23:28:44 +01:00
Owain G. Ainsworth
d6161f0d41 fix ScriptToAddress when called with 0 length script.
It did work by luck before, but now it works no matter what the template
tables say. Add tests for the other error cases and internal data
assertions.
2013-06-26 22:11:54 +01:00
Owain G. Ainsworth
7ae307abfd Fix case where we have an empty script that isn't the first.
Silly check needed to confirm it was the first script. Add test for this case.
2013-06-26 14:16:00 +01:00
Dave Collins
166a546078 Modify DropAfterBlockBySha to accept a pointer.
Since all other functions take pointers, this makes the interface more
consistent.
2013-06-25 10:15:58 -05:00
Owain G. Ainsworth
7e937fae75 testing for the case where a p2sh sigscript isn't pushonly.
Also providing a defined error (from NewScript) for that case.
2013-06-25 13:12:15 +01:00
Owain G. Ainsworth
4a87e6e3a7 Test a few failure cases of p2sh txs. 2013-06-25 00:12:08 +01:00
Owain G. Ainsworth
ba51aa8934 partially revert afc2e8100a
Turns out that there are some signatures in the bitcoin blockchain that have
trailing 0s, for example
12a1b29fd6c295075b6a66f5fd90f0126ceb1fda4f15e4b44d92518bd52a5cdf has a signature
length of 0x45 where there are 0x47 bytes following that length check (one is
hashtype and is supposed to be trimmed out prior to calling the function). We
relax the paranoid length check to permit traling data, but not to permit
buffers that are too short. Change the test to passing with a big comment
stating why this is now considered a valid case.
2013-06-24 18:15:25 +01:00
Owain G. Ainsworth
2bdaebfa74 some more tests for GetPreciseSigOpsCount. total coverage now. 2013-06-24 16:32:41 +01:00
Owain G. Ainsworth
53ba8fb834 gofmt 2013-06-21 01:33:56 +01:00
Owain G. Ainsworth
8fe24958bb Test the unfinished condition of CheckErrorCondition 2013-06-21 01:33:38 +01:00
Owain G. Ainsworth
03696a8874 Add functions to count the number of signature operations in a script.
To be usd for validation. Most of the codepaths teste, a few tests
missing for cases needed tests in the validation codepaths too. To be
worked on in tree.
2013-06-20 20:10:30 +01:00
Owain G. Ainsworth
421a213a4f Stop modifying the passed tx in NewScript.
The only time we need to zero out scripts is for calcScriptHash which operates
on a deep copy anyway. This should make the tx passed to us unmodified now.
2013-06-20 20:10:05 +01:00
Dave Collins
d54fba85b4 Export the MaxBlockPayload constant.
Although you can technically get at this value via the MaxPayloadLength
function on a block, it is less overhead for any consumers that need to
know the value to simply export it directly.
2013-06-20 13:09:44 -05:00
Owain G. Ainsworth
25624bc6a7 check that OP_CHECK_MULTISIG also triggers on too many ops 2013-06-20 01:21:12 +01:00
Owain G. Ainsworth
bac455cdd2 Fix reversed test bug with the max operations handling
We were counting the number of push ops instead of the number of non
push ops.  Add tests that found this (checking tha the max operations
check fires).
2013-06-20 00:30:34 +01:00
Owain G. Ainsworth
8035de426b Check that the pc validation code works ok.
Add a testing only interface to set the pc and set it to a few invalid
settings to check that step and disasmPC all blow up correctly.
2013-06-19 23:31:44 +01:00
Owain G. Ainsworth
625541e202 add some testing for byte format in stack.PushInt()
should verify all the formats now.

pain causes endian little.
2013-06-19 01:06:02 +01:00
Owain G. Ainsworth
501b711301 int.Sign() in go will never return negative for zero.
So remove the -0 handling in fromInt, only toInt needs it.
2013-06-19 00:51:48 +01:00
Owain G. Ainsworth
5e82baf476 add some basic tests for stack.PopInt() 2013-06-19 00:38:57 +01:00
Owain G. Ainsworth
4692d64f68 permit tests expect fail for nonspecified return code.
Use this to test the pubkey paths in checksig which return btcec errors
which we don't define. all of the other active tests know the return
code we need.
2013-06-18 23:36:44 +01:00
Owain G. Ainsworth
df0c0b27d1 Factor the end-of-script error handling into a function.
Use it to reduce code dpulication in the bip16 case.

In addition we export it so that that a user could run:
for !done && err == nil {
	done, err = s.Step()
}
err = s.CheckErrorCondition()

manually instead of having to run Execute().
2013-06-18 17:44:29 +01:00
Owain G. Ainsworth
7b08a4e127 Number of operations is per-script not per-transaction.
Reset the counter at the end of each script.
2013-06-18 17:44:18 +01:00
Owain G. Ainsworth
bc41004b03 Use errors.New() not fmt.Errorf() when no fmt string. 2013-06-18 17:44:15 +01:00
Owain G. Ainsworth
031437decf test 0 length numbers (disallowed) and coordinates of 0 (also) 2013-06-18 00:17:32 +01:00
Owain G. Ainsworth
13cf6091e6 Test the sanity checks for numbers too big for the curve fire correctly. 2013-06-17 23:58:47 +01:00
Owain G. Ainsworth
86d150bbb3 Remove accidentally commited printf. 2013-06-17 23:56:25 +01:00
Owain G. Ainsworth
316faf034c update test coverage stats. 2013-06-17 17:41:37 +01:00
Owain G. Ainsworth
afc2e8100a Make length check a little more paranoid
Remove trailing crap  from the tests (the hashtype) now that this is
correctly caught.
2013-06-17 17:38:16 +01:00
Owain G. Ainsworth
cd61efe8a8 test a bunch of invalid cases in ParseSignature. 2013-06-17 16:18:58 +01:00
Owain G. Ainsworth
5c8c454a18 fix up some indexing in ParseSignature.
a test i was working on was crashing this otherwise. Make length checks more
paranoid.
2013-06-17 16:18:27 +01:00
Dave Collins
10542e0573 Optimize and improve credential stripping code.
Since we already have the specific username and password we want to strip
from errors, use a specific search string rather than a generic regular
expression.  This is quite a bit more efficient than using regular
expressions and also has the benefit of being more accurate.

Also, rather than using the added overhead of fmt to convert the error to
a string, just call Error() directly on it to get the string.

Finally, instead of just stripping it, replace it with the literal
string "<username>:<password>" to avoid any possible confusion in the
error messages where it might otherwise appear the url was being
constructed incorrectly.

ok jcv@
2013-06-14 11:32:50 -05:00
John C. Vernaleo
2a475d7299 Need to test for nil before regex. 2013-06-14 11:47:09 -04:00
John C. Vernaleo
21d1240502 Update test_coverage.txt 2013-06-14 11:36:44 -04:00
John C. Vernaleo
e4a80edc95 Clean the error message on connect failure so username and password is not shown. 2013-06-14 11:32:05 -04:00
Owain G. Ainsworth
9cb1f47fb9 add signature test harness and try a valid signature for size.
error paths to come.
2013-06-14 01:11:06 +01:00
Owain G. Ainsworth
7cfebed976 Test the ``parameter is >= P'' pubkey error paths. 2013-06-14 00:28:54 +01:00
Owain G. Ainsworth
9638528b8e test hybrid keys too.
Nothing that I know of uses them, but if we have the code path we should
be pretty sure it works.
2013-06-14 00:06:25 +01:00
Owain G. Ainsworth
217fa5311a go fmt. *sigh* 2013-06-14 00:03:15 +01:00
Owain G. Ainsworth
ffdbcd5cce test a few easy to hit pubkey error paths. 2013-06-13 23:55:52 +01:00