Stoppable.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. contract('Stoppable', function(accounts) {
  2. it("can perform normal process in non-emergency", async function(done) {
  3. let stoppable = await StoppableMock.new();
  4. let count0 = await stoppable.count();
  5. assert.equal(count0, 0);
  6. let normalProcess = await stoppable.normalProcess();
  7. let count1 = await stoppable.count();
  8. assert.equal(count1, 1);
  9. done();
  10. });
  11. it("can not perform normal process in emergency", async function(done) {
  12. let stoppable = await StoppableMock.new();
  13. let emergencyStop = await stoppable.emergencyStop();
  14. let count0 = await stoppable.count();
  15. assert.equal(count0, 0);
  16. let normalProcess = await stoppable.normalProcess();
  17. let count1 = await stoppable.count();
  18. assert.equal(count1, 0);
  19. done();
  20. });
  21. it("can not take drastic measure in non-emergency", async function(done) {
  22. let stoppable = await StoppableMock.new();
  23. let drasticMeasure = await stoppable.drasticMeasure();
  24. let drasticMeasureTaken = await stoppable.drasticMeasureTaken();
  25. assert.isFalse(drasticMeasureTaken);
  26. done();
  27. });
  28. it("can take a drastic measure in an emergency", async function(done) {
  29. let stoppable = await StoppableMock.new();
  30. let emergencyStop = await stoppable.emergencyStop();
  31. let drasticMeasure = await stoppable.drasticMeasure();
  32. let drasticMeasureTaken = await stoppable.drasticMeasureTaken();
  33. assert.isTrue(drasticMeasureTaken);
  34. done();
  35. });
  36. it("should resume allowing normal process after emergency is over", async function(done) {
  37. let stoppable = await StoppableMock.new();
  38. let emergencyStop = await stoppable.emergencyStop();
  39. let release = await stoppable.release();
  40. let normalProcess = await stoppable.normalProcess();
  41. let count0 = await stoppable.count();
  42. assert.equal(count0, 1);
  43. done();
  44. });
  45. });