public bool Before_eip_1559_has_to_be_legacy_or_access_list_tx(TxType txType, bool eip2930, bool eip1559) { byte[] sigData = new byte[65]; sigData[31] = 1; // correct r sigData[63] = 1; // correct s sigData[64] = 38; Signature signature = new(sigData); Transaction tx = Build.A.Transaction .WithType(txType) .WithChainId(ChainId.Mainnet) .WithMaxPriorityFeePerGas(txType == TxType.EIP1559 ? 10.GWei() : 5.GWei()) .WithMaxFeePerGas(txType == TxType.EIP1559 ? 10.GWei() : 5.GWei()) .WithAccessList(txType == TxType.AccessList || txType == TxType.EIP1559 ? new AccessList(new Dictionary <Address, IReadOnlySet <UInt256> >()) : null) .WithSignature(signature).TestObject; tx.Type = txType; TxValidator txValidator = new(1); IReleaseSpec releaseSpec = new ReleaseSpec() { IsEip2930Enabled = eip2930, IsEip1559Enabled = eip1559 }; return(txValidator.IsWellFormed(tx, releaseSpec)); }
public TestingContext(bool isEip1559Enabled = false, long eip1559TransitionBlock = 0) { ReleaseSpec releaseSpec = new ReleaseSpec(); ReleaseSpec eip1559ReleaseSpec = new ReleaseSpec() { IsEip1559Enabled = isEip1559Enabled, Eip1559TransitionBlock = eip1559TransitionBlock }; ISpecProvider specProvider = Substitute.For <ISpecProvider>(); specProvider.GetSpec(Arg.Is <long>(x => x >= eip1559TransitionBlock)).Returns(eip1559ReleaseSpec); specProvider.GetSpec(Arg.Is <long>(x => x < eip1559TransitionBlock)).Returns(releaseSpec); _blockTree = Substitute.For <IBlockTree>(); UpdateBlockTreeHead(); _transactionComparerProvider = new TransactionComparerProvider(specProvider, _blockTree); }
public void When_more_uncles_than_allowed_returns_false() { TxValidator txValidator = new TxValidator(ChainId.MainNet); ReleaseSpec releaseSpec = new ReleaseSpec(); releaseSpec.MaximumUncleCount = 0; ISpecProvider specProvider = new CustomSpecProvider((0, releaseSpec)); BlockValidator blockValidator = new BlockValidator(txValidator, AlwaysValidHeaderValidator.Instance, AlwaysValidOmmersValidator.Instance, specProvider, LimboLogs.Instance); bool noiseRemoved = blockValidator.ValidateSuggestedBlock(Build.A.Block.TestObject); Assert.True(noiseRemoved); bool result = blockValidator.ValidateSuggestedBlock(Build.A.Block.WithOmmers(Build.A.BlockHeader.TestObject).TestObject); Assert.False(result); }
public void Eip_158_touch_zero_value_system_account_is_not_deleted() { StateProvider provider = new StateProvider(new StateDb(new MemDb()), Substitute.For <IDb>(), Logger); var systemUser = Address.SystemUser; provider.CreateAccount(systemUser, 0); provider.Commit(Homestead.Instance); var releaseSpec = new ReleaseSpec() { IsEip158Enabled = true }; provider.UpdateCodeHash(systemUser, Keccak.OfAnEmptyString, releaseSpec); provider.Commit(releaseSpec); provider.GetAccount(systemUser).Should().NotBeNull(); }