-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle exception for get_signing_address to get previous behaviour
- Before deprecating `pyethereum` NULL_ADDRESS was returned instead of raising an exception
- Loading branch information
Showing
2 changed files
with
35 additions
and
3 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from django.test import TestCase | ||
|
||
from eth_account import Account | ||
from web3 import Web3 | ||
|
||
from gnosis.eth.constants import NULL_ADDRESS | ||
|
||
from ..signatures import get_signing_address | ||
|
||
|
||
class TestSafeSignature(TestCase): | ||
def test_get_signing_address(self): | ||
account = Account.create() | ||
# Random hash | ||
random_hash = Web3.keccak(text="tanxugueiras") | ||
signature = account.signHash(random_hash) | ||
self.assertEqual( | ||
get_signing_address(random_hash, signature.v, signature.r, signature.s), | ||
account.address, | ||
) | ||
|
||
# Invalid signature will return the `NULL_ADDRESS` | ||
self.assertEqual( | ||
get_signing_address(random_hash, signature.v - 8, signature.r, signature.s), | ||
NULL_ADDRESS, | ||
) |