From b8793edd836f816014c38b90edebced246759af7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Tue, 13 Jun 2017 13:39:39 +0300 Subject: [PATCH] mobile: add a regression test for signer recovery --- mobile/android_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/mobile/android_test.go b/mobile/android_test.go index 6f5076d64..345e009b4 100644 --- a/mobile/android_test.go +++ b/mobile/android_test.go @@ -37,6 +37,9 @@ package go; import android.test.InstrumentationTestCase; import android.test.MoreAsserts; +import java.math.BigInteger; +import java.util.Arrays; + import org.ethereum.geth.*; public class AndroidTest extends InstrumentationTestCase { @@ -115,6 +118,32 @@ public class AndroidTest extends InstrumentationTestCase { fail(e.toString()); } } + + // Tests that recovering transaction signers works for both Homestead and EIP155 + // signatures too. Regression test for go-ethereum issue #14599. + public void testIssue14599() { + try { + byte[] preEIP155RLP = new BigInteger("f901fc8032830138808080b901ae60056013565b6101918061001d6000396000f35b3360008190555056006001600060e060020a6000350480630a874df61461003a57806341c0e1b514610058578063a02b161e14610066578063dbbdf0831461007757005b610045600435610149565b80600160a060020a031660005260206000f35b610060610161565b60006000f35b6100716004356100d4565b60006000f35b61008560043560243561008b565b60006000f35b600054600160a060020a031632600160a060020a031614156100ac576100b1565b6100d0565b8060018360005260205260406000208190555081600060005260206000a15b5050565b600054600160a060020a031633600160a060020a031614158015610118575033600160a060020a0316600182600052602052604060002054600160a060020a031614155b61012157610126565b610146565b600060018260005260205260406000208190555080600060005260206000a15b50565b60006001826000526020526040600020549050919050565b600054600160a060020a031633600160a060020a0316146101815761018f565b600054600160a060020a0316ff5b561ca0c5689ed1ad124753d54576dfb4b571465a41900a1dff4058d8adf16f752013d0a01221cbd70ec28c94a3b55ec771bcbc70778d6ee0b51ca7ea9514594c861b1884", 16).toByteArray(); + preEIP155RLP = Arrays.copyOfRange(preEIP155RLP, 1, preEIP155RLP.length); + + byte[] postEIP155RLP = new BigInteger("f86b80847735940082520894ef5bbb9bba2e1ca69ef81b23a8727d889f3ef0a1880de0b6b3a7640000802ba06fef16c44726a102e6d55a651740636ef8aec6df3ebf009e7b0c1f29e4ac114aa057e7fbc69760b522a78bb568cfc37a58bfdcf6ea86cb8f9b550263f58074b9cc", 16).toByteArray(); + postEIP155RLP = Arrays.copyOfRange(postEIP155RLP, 1, postEIP155RLP.length); + + Transaction preEIP155 = new Transaction(preEIP155RLP); + Transaction postEIP155 = new Transaction(postEIP155RLP); + + preEIP155.getFrom(null); // Homestead should accept homestead + preEIP155.getFrom(new BigInt(4)); // EIP155 should accept homestead (missing chain ID) + postEIP155.getFrom(new BigInt(4)); // EIP155 should accept EIP 155 + + try { + postEIP155.getFrom(null); + fail("EIP155 transaction accepted by Homestead"); + } catch (Exception e) {} + } catch (Exception e) { + fail(e.toString()); + } + } } `