Eip160HFConfig extends Eip150HFConfig { @Override public boolean acceptTransactionSignature(Transaction tx) { if (tx.getSignature() == null) return false; if (!tx.getSignature().validateComponents() || tx.getSignature().s.compareTo(SECP256K1N_HALF) > 0) return false; return tx.getChainId() == null || Objects.equals(getChainId(), tx.getChainId()); } Eip160HFConfig(BlockchainConfig parent); @Override GasCost getGasCost(); @Override boolean eip161(); @Override Integer getChainId(); @Override Constants getConstants(); @Override boolean acceptTransactionSignature(Transaction tx);  }
@Test public void testAcceptTransactionWithSignature() throws Exception { Transaction tx = Transaction.create( "3535353535353535353535353535353535353535", new BigInteger("1000000000000000000"), new BigInteger("9"), new BigInteger("20000000000"), new BigInteger("21000"), 1); ECKey ecKey = ECKey.fromPrivate(Hex.decode("4646464646464646464646464646464646464646464646464646464646464646")); tx.sign(ecKey); TestBlockchainConfig parent = new TestBlockchainConfig(); Eip160HFConfig config = new Eip160HFConfig(parent); assertTrue(config.acceptTransactionSignature(tx)); }
@Test public void testDenyTransactionWithInvalidSignature() throws Exception { Transaction tx = Transaction.create( "3535353535353535353535353535353535353535", new BigInteger("1000000000000000000"), new BigInteger("9"), new BigInteger("20000000000"), new BigInteger("21000"), 1); ECKey ecKey = ECKey.fromPrivate(Hex.decode("4646464646464646464646464646464646464646464646464646464646464646")); tx.sign(ecKey); TestBlockchainConfig parent = new TestBlockchainConfig(); Eip160HFConfig config = new Eip160HFConfig(parent); tx.getSignature().v = 99; assertFalse(config.acceptTransactionSignature(tx)); }
@Test public void testDenyTransactionWithoutSignature() throws Exception { TestBlockchainConfig parent = new TestBlockchainConfig(); Eip160HFConfig config = new Eip160HFConfig(parent); Transaction txWithoutSignature = new Transaction(emptyBytes, emptyBytes, emptyBytes, emptyBytes, emptyBytes, emptyBytes, null); assertFalse(config.acceptTransactionSignature(txWithoutSignature)); }