def test_recover_changed_signature(ethereum_accounts):
    transaction = Transaction().sign(HexBytes(ethereum_accounts[0].key)).raw_transaction
    signature = Transaction().sign(ethereum_accounts[1].key).signature
    signed = SignedTransaction(transaction, signature)

    with pytest.raises(WrongSignatureError):
        signed.ecrecover()
def test_recover_changed_body(ethereum_accounts):
    signature = Transaction().sign(ethereum_accounts[0].key).signature
    data = {
        'name': 'polyswarmtransaction.transaction:Transaction',
        'from': '0x3f17f1962B36e491b30A40b2405849e597Ba5FB5',
        'data': {
            'different': 'asdf'
        }
    }
    signed = SignedTransaction(json.dumps(data), signature)

    with pytest.raises(WrongSignatureError):
        signed.ecrecover()
Пример #3
0
def test_recover_assertion_signed_transaction_from_signed_output(
        ethereum_accounts):
    transaction = AssertionTransaction('test', True, '1000000000000000000',
                                       ASSERTION_METADATA)
    signed = transaction.sign(ethereum_accounts[0].key)
    signed = SignedTransaction(**signed.payload)
    assert signed.ecrecover() == '0x3f17f1962B36e491b30A40b2405849e597Ba5FB5'
Пример #4
0
def test_recover_bounty_signed_transaction_from_signed_output(
        ethereum_accounts):
    transaction = BountyTransaction('test', '2000000000000000000', 'Qm',
                                    ArtifactType.FILE.value, 123,
                                    BOUNTY_METADATA)
    signed = transaction.sign(ethereum_accounts[0].key)
    signed = SignedTransaction(**signed.payload)
    assert signed.ecrecover() == '0x3f17f1962B36e491b30A40b2405849e597Ba5FB5'
Пример #5
0
def test_recover_release_signed_transaction_from_signed_output(ethereum_accounts):
    transaction = ApproveNectarReleaseTransaction(destination='0x0000000000000000000000000000000000000001',
                                       amount='200000000000000000',
                                       transaction_hash='0x0000000000000000000000000000000',
                                       block_hash='0x0000000000000000000000000000000',
                                       block_number='0x1')
    signed = transaction.sign(ethereum_accounts[0].key)
    signed = SignedTransaction(**signed.payload)
    assert signed.ecrecover() == '0x3f17f1962B36e491b30A40b2405849e597Ba5FB5'
def test_recover_signed_transaction_from_parts():
    signature = ('0xed2e8602439eec57a84bb372c6de718d88d2c27f265d7c01fe59a940f9c44eb25f849639669897e376dca6b3e745f4d966'
                 '732f731b6ec20d908673ad882aeed301')
    # Must be a string exact match
    data = {
        'name': 'polyswarmtransaction.transaction:Transaction',
        'from': '0x3f17f1962B36e491b30A40b2405849e597Ba5FB5',
        'data': {}
    }
    signed = SignedTransaction(json.dumps(data), signature)
    assert signed.ecrecover() == '0x3f17f1962B36e491b30A40b2405849e597Ba5FB5'
Пример #7
0
def test_recover_withdrawal_signed_transaction_from_parts():
    signature = ('0x92787e13b8b556e24d5316e58a344b3feca1b5559571de63eb64160e874bfb78710848fd20e6fe45c5cb19b0adee22ccf1'
                 '248eefe3fd8ad39e47281ee25b2b8d01')
    data = {
        'name': 'polyswarmtransaction.nectar:WithdrawalTransaction',
        'from': '0x3f17f1962B36e491b30A40b2405849e597Ba5FB5',
        'data': {
            'amount': '2000000000000000000'
        }
    }
    signed = SignedTransaction(json.dumps(data), signature)
    assert signed.ecrecover() == '0x3f17f1962B36e491b30A40b2405849e597Ba5FB5'
Пример #8
0
def test_recover_vote_signed_transaction_from_parts():
    signature = (
        '0xc04b6d31e94c26faa039b899e4c58adecc74bff57b3985668f5ba59ce27a0bf301d41b1b07a1117d6c16d6bb31a44da680'
        'e215178c121988462be4891d86935101')
    data = {
        'name': 'polyswarmtransaction.bounty:VoteTransaction',
        'from': '0x3f17f1962B36e491b30A40b2405849e597Ba5FB5',
        'data': {
            'guid': 'test',
            'vote': True,
        }
    }
    signed = SignedTransaction(json.dumps(data), signature)
    assert signed.ecrecover() == '0x3f17f1962B36e491b30A40b2405849e597Ba5FB5'
Пример #9
0
def test_recover_release_signed_transaction_from_parts():
    signature = ('0x7f9f551b25397ed66c7aa0dbb5ad92a09ce5c976fa5492d0c3324fbd46b09cba7325d13b74038ab63cbcc369216983b94b'
                 '507a876ee13eac8b95ff05a69de36200')
    data = {
        'name': 'polyswarmtransaction.nectar:ApproveNectarReleaseTransaction',
        'from': '0x3f17f1962B36e491b30A40b2405849e597Ba5FB5',
        'data': {
            'destination': '0x0000000000000000000000000000000000000001',
            'amount': '200000000000000000',
            'transaction_hash': '0x0000000000000000000000000000000',
            'block_hash': '0x0000000000000000000000000000000',
            'block_number': '0x1',
        }
    }
    signed = SignedTransaction(json.dumps(data), signature)
    assert signed.ecrecover() == '0x3f17f1962B36e491b30A40b2405849e597Ba5FB5'
Пример #10
0
def test_recover_assertion_signed_transaction_from_parts():
    signature = (
        '0x0b2e16aff5f17c95434d06201514c20aed27d899649679cce01327afca495d3c17fc9f8f12551031aeae28a744be4fddf6'
        '8b46155b24472d6f9d0da0ffa5376c00')
    data = {
        'name': 'polyswarmtransaction.bounty:AssertionTransaction',
        'from': '0x3f17f1962B36e491b30A40b2405849e597Ba5FB5',
        'data': {
            'guid': 'test',
            'verdict': True,
            'bid': '1000000000000000000',
            'metadata': {
                'malware_family': ''
            }
        }
    }
    signed = SignedTransaction(json.dumps(data), signature)
    assert signed.ecrecover() == '0x3f17f1962B36e491b30A40b2405849e597Ba5FB5'
Пример #11
0
def test_recover_bounty_signed_transaction_from_parts():
    signature = (
        '0x2593843d5ef54ba3588e2d8a9a2b205124612787d7309736ae430dc99c0e797b2ac7975ffc405ff551ef17ae16993fdfca'
        '22310cb71d638d8971ec51cefd49ec01')
    data = {
        'name': 'polyswarmtransaction.bounty:BountyTransaction',
        'from': '0x3f17f1962B36e491b30A40b2405849e597Ba5FB5',
        'data': {
            'guid': 'test',
            'reward': '2000000000000000000',
            'artifact': 'Qm',
            'artifact_type': 0,
            'duration': 123,
            'metadata': [{
                'mimetype': ''
            }]
        }
    }
    signed = SignedTransaction(json.dumps(data), signature)
    assert signed.ecrecover() == '0x3f17f1962B36e491b30A40b2405849e597Ba5FB5'
def test_recover_empty_signature():
    signed = SignedTransaction('', '')
    with pytest.raises(InvalidSignatureError):
        signed.ecrecover()
def test_recover_signed_transaction_from_payload(ethereum_accounts):
    transaction = Transaction()
    signed = transaction.sign(ethereum_accounts[0].key)
    signed = SignedTransaction(**signed.payload)
    assert signed.ecrecover() == '0x3f17f1962B36e491b30A40b2405849e597Ba5FB5'
def test_recover_signed_transaction_from_signed_output(ethereum_accounts):
    transaction = Transaction()
    signed = transaction.sign(ethereum_accounts[0].key)
    signed = SignedTransaction(signed.raw_transaction, signed.signature)
    assert signed.ecrecover() == '0x3f17f1962B36e491b30A40b2405849e597Ba5FB5'
Пример #15
0
def test_recover_withdrawal_signed_transaction_from_signed_output(ethereum_accounts):
    transaction = WithdrawalTransaction('2000000000000000000')
    signed = transaction.sign(ethereum_accounts[0].key)
    signed = SignedTransaction(**signed.payload)
    assert signed.ecrecover() == '0x3f17f1962B36e491b30A40b2405849e597Ba5FB5'
Пример #16
0
def test_recover_vote_signed_transaction_from_signed_output(ethereum_accounts):
    transaction = VoteTransaction('test', True)
    signed = transaction.sign(ethereum_accounts[0].key)
    signed = SignedTransaction(**signed.payload)
    assert signed.ecrecover() == '0x3f17f1962B36e491b30A40b2405849e597Ba5FB5'