Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
test_sha256.py
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
You can’t perform that action at this time.