public void ContractPatcher_Test() { var code = ReadContractCode(typeof(TokenContract)); var updateCode = ContractPatcher.Patch(code); code.ShouldNotBe(updateCode); var exception = Record.Exception(() => _auditorFixture.Audit(updateCode)); exception.ShouldBeNull(); }
public void ContractPatcher_Test() { const string contract = "AElf.Contracts.MultiToken.dll"; var code = ReadCode(Path.Combine(_contractDllDir, contract)); var updateCode = ContractPatcher.Patch(code); code.ShouldNotBe(updateCode); var exception = Record.Exception(() => _auditorFixture.Audit(updateCode)); exception.ShouldBeNull(); }
public void CheckPatchAudit_ForUncheckedMathOpcodes() { // Here, we use any contract that contains unchecked math OpCode even with "Check for arithmetic overflow" // checked in the project. If first section of below test case fails, need to create another contract // that iterates an array with foreach loop. var contractCode = ReadCode(_contractDllDir + typeof(TransactionFeesContract).Module); var findings = Should.Throw <InvalidCodeException>( () => _auditorFixture.Audit(contractCode)) .Findings; findings.FirstOrDefault(f => f is UncheckedMathValidationResult) .ShouldNotBeNull(); // After patching, all unchecked arithmetic OpCodes should be cleared. Should.NotThrow(() => _auditorFixture.Audit(ContractPatcher.Patch(contractCode))); }
public void PatchTest() { ContractPatcher.Patch(ReadContractCode(typeof(AEDPoSContract))); }