Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. contract C {
  2. uint x;
  3. function f() public {
  4. require(x + 1 > x);
  5. ++x;
  6. }
  7. function g() public {
  8. uint y = x;
  9. f();
  10. assert(y == (x - 1));
  11. }
  12. }
  13.  
  14. contract C {
  15. uint x;
  16. function f() public {
  17. require(x + 1 > x);
  18. ++x;
  19. }
  20. function g() public {
  21. require(x > 10);
  22. uint y = x;
  23. uint i = 0;
  24. for (; i < 10; ++i)
  25. f();
  26. assert(y == (x - 10));
  27. }
  28. }
  29.  
  30. contract A {
  31. int public s;
  32. B b;
  33.  
  34. constructor() public { s=0; b = new B(this);}
  35.  
  36. function f() public {
  37. require(s+1>s);
  38. bool status;
  39. bytes memory result;
  40. int s0=s;
  41. (status, result) = address(b).call.gas(10000)(abi.encodePacked(bytes4(keccak256("g()"))));
  42. assert(s0==s);
  43. incs();
  44. assert(s>0);
  45. }
  46.  
  47. function getBs() public view returns(int) {return b.s();}
  48. function incs() public {s+=1;}
  49. }
  50.  
  51. contract B{
  52. int public s;
  53. A a;
  54. constructor(A _a) public {s=0; a=_a;}
  55. function g() external {
  56. s+=1;
  57. a.incs();
  58. assert(false);
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement