예제 #1
0
async def test_set_signer_invalid_nonce(contract_factory):
    """Should fail to update the signer with a bad nonce"""
    _, contract = contract_factory

    nonce = 666
    message_hash = pedersen_hash(
        nonce, pedersen_hash(some_vehicle, pedersen_hash(some_other_signer,
                                                         0)))
    sig_r, sig_s = sign(msg_hash=message_hash, priv_key=some_owner_secret)

    with pytest.raises(StarkException):
        await contract.set_signer(
            vehicle_id=some_vehicle,
            nonce=nonce,
            signer_public_key=some_other_signer,
        ).invoke(signature=[sig_r, sig_s])
예제 #2
0
async def test_attest_state(contract_factory):
    """Should successfully attest to a state hash & increment nonce"""
    _, contract = contract_factory

    state_hash = 1234
    nonce = 0
    message_hash = pedersen_hash(
        nonce, pedersen_hash(some_vehicle, pedersen_hash(state_hash, 0)))
    sig_r, sig_s = sign(msg_hash=message_hash, priv_key=some_signer_secret)

    await contract.attest_state(
        vehicle_id=some_vehicle,
        nonce=nonce,
        state_hash=state_hash,
    ).invoke(signature=[sig_r, sig_s])

    # Check the nonce was incremented
    new_nonce = await contract.get_nonce(vehicle_id=some_vehicle).call()
    assert new_nonce.result == (nonce + 1, )