Created
March 3, 2015 14:07
-
-
Save jorisbontje/f19a6355983fc45102f4 to your computer and use it in GitHub Desktop.
test_sha256.py
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
import bitcoin as b | |
from pyethereum import tester, utils | |
class TestSHA256(object): | |
CONTRACT = """ | |
def func(): | |
return(sha256([1,2], items=2)) | |
""" | |
def setup_class(cls): | |
cls.s = tester.state() | |
cls.c = cls.s.abi_contract(cls.CONTRACT) | |
cls.snapshot = cls.s.snapshot() | |
def setup_method(self, method): | |
self.s.revert(self.snapshot) | |
def test_func(self): | |
ints = ''.join([utils.zpad(utils.int_to_big_endian(x), 32) for x in [1, 2]]) | |
hash = b.sha256(ints) | |
assert self.c.func() == int(hash, 16) - 2**256 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment