You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 lines
4.5 KiB

  1. package eth
  2. import (
  3. "math/big"
  4. "testing"
  5. "github.com/stretchr/testify/assert"
  6. "github.com/stretchr/testify/require"
  7. )
  8. var wdelayerClient *WDelayerClient
  9. // var wdelayerClientKep *WDelayerClient
  10. var initWithdrawalDelay = big.NewInt(60)
  11. var newWithdrawalDelay = big.NewInt(79)
  12. func TestWDelayerGetHermezGovernanceDAOAddress(t *testing.T) {
  13. governanceAddress, err := wdelayerClient.WDelayerGetHermezGovernanceDAOAddress()
  14. require.Nil(t, err)
  15. assert.Equal(t, &hermezGovernanceDAOAddressConst, governanceAddress)
  16. }
  17. func TestWDelayerSetHermezGovernanceDAOAddress(t *testing.T) {
  18. wdelayerClientGov := NewWDelayerClient(ethereumClientGovDAO, wdelayerAddressConst)
  19. _, err := wdelayerClientGov.WDelayerSetHermezGovernanceDAOAddress(auxAddressConst)
  20. require.Nil(t, err)
  21. auxAddress, err := wdelayerClient.WDelayerGetHermezGovernanceDAOAddress()
  22. require.Nil(t, err)
  23. assert.Equal(t, &auxAddressConst, auxAddress)
  24. wdelayerClientAux := NewWDelayerClient(ethereumClientAux, wdelayerAddressConst)
  25. _, err = wdelayerClientAux.WDelayerSetHermezGovernanceDAOAddress(hermezGovernanceDAOAddressConst)
  26. require.Nil(t, err)
  27. }
  28. func TestWDelayerGetHermezKeeperAddress(t *testing.T) {
  29. keeperAddress, err := wdelayerClient.WDelayerGetHermezKeeperAddress()
  30. require.Nil(t, err)
  31. assert.Equal(t, &hermezKeeperAddressConst, keeperAddress)
  32. }
  33. func TestWDelayerSetHermezKeeperAddress(t *testing.T) {
  34. wdelayerClientKep := NewWDelayerClient(ethereumClientKep, wdelayerAddressConst)
  35. _, err := wdelayerClientKep.WDelayerSetHermezKeeperAddress(auxAddressConst)
  36. require.Nil(t, err)
  37. auxAddress, err := wdelayerClient.WDelayerGetHermezKeeperAddress()
  38. require.Nil(t, err)
  39. assert.Equal(t, &auxAddressConst, auxAddress)
  40. wdelayerClientAux := NewWDelayerClient(ethereumClientAux, wdelayerAddressConst)
  41. _, err = wdelayerClientAux.WDelayerSetHermezKeeperAddress(hermezKeeperAddressConst)
  42. require.Nil(t, err)
  43. }
  44. func TestWDelayerGetWhiteHackGroupAddress(t *testing.T) {
  45. whiteHackGroupAddress, err := wdelayerClient.WDelayerGetWhiteHackGroupAddress()
  46. require.Nil(t, err)
  47. assert.Equal(t, &whiteHackGroupAddressConst, whiteHackGroupAddress)
  48. }
  49. func TestWDelayerSetWhiteHackGroupAddress(t *testing.T) {
  50. wdelayerClientWhite := NewWDelayerClient(ethereumClientWhite, wdelayerAddressConst)
  51. _, err := wdelayerClientWhite.WDelayerSetWhiteHackGroupAddress(auxAddressConst)
  52. require.Nil(t, err)
  53. auxAddress, err := wdelayerClient.WDelayerGetWhiteHackGroupAddress()
  54. require.Nil(t, err)
  55. assert.Equal(t, &auxAddressConst, auxAddress)
  56. wdelayerClientAux := NewWDelayerClient(ethereumClientAux, wdelayerAddressConst)
  57. _, err = wdelayerClientAux.WDelayerSetWhiteHackGroupAddress(whiteHackGroupAddressConst)
  58. require.Nil(t, err)
  59. }
  60. func TestWDelayerIsEmergencyMode(t *testing.T) {
  61. emergencyMode, err := wdelayerClient.WDelayerIsEmergencyMode()
  62. require.Nil(t, err)
  63. assert.Equal(t, false, emergencyMode)
  64. }
  65. func TestWDelayerGetWithdrawalDelay(t *testing.T) {
  66. withdrawalDelay, err := wdelayerClient.WDelayerGetWithdrawalDelay()
  67. require.Nil(t, err)
  68. assert.Equal(t, initWithdrawalDelay, withdrawalDelay)
  69. }
  70. func TestWDelayerEnableEmergencyMode(t *testing.T) {
  71. wdelayerClientKep := NewWDelayerClient(ethereumClientKep, wdelayerAddressConst)
  72. _, err := wdelayerClientKep.WDelayerEnableEmergencyMode()
  73. require.Nil(t, err)
  74. emergencyMode, err := wdelayerClient.WDelayerIsEmergencyMode()
  75. require.Nil(t, err)
  76. assert.Equal(t, true, emergencyMode)
  77. }
  78. func TestWDelayerChangeWithdrawalDelay(t *testing.T) {
  79. wdelayerClientKep := NewWDelayerClient(ethereumClientKep, wdelayerAddressConst)
  80. _, err := wdelayerClientKep.WDelayerChangeWithdrawalDelay(newWithdrawalDelay.Uint64())
  81. require.Nil(t, err)
  82. withdrawalDelay, err := wdelayerClient.WDelayerGetWithdrawalDelay()
  83. require.Nil(t, err)
  84. assert.Equal(t, newWithdrawalDelay, withdrawalDelay)
  85. }
  86. func TestWDelayerGetEmergencyModeStartingTime(t *testing.T) {
  87. emergencyModeStartingTime, err := wdelayerClient.WDelayerGetEmergencyModeStartingTime()
  88. require.Nil(t, err)
  89. // `emergencyModeStartingTime` is initialized to 0 in the smart
  90. // contract construction. Since we called WDelayerEnableEmergencyMode
  91. // previously, `emergencyModeStartingTime` is set to the time when the
  92. // call was made, so it's > 0.
  93. assert.True(t, emergencyModeStartingTime.Cmp(big.NewInt(0)) == 1)
  94. }
  95. /* func TestWDelayerDeposit(t *testing.T) {
  96. if wdelayerClient != nil {
  97. }
  98. }
  99. func TestWDelayerDepositInfo(t *testing.T) {
  100. if wdelayerClient != nil {
  101. }
  102. }
  103. func TestWDelayerWithdrawal(t *testing.T) {
  104. if wdelayerClient != nil {
  105. }
  106. }
  107. func TestWDelayerEscapeHatchWithdrawal(t *testing.T) {
  108. if wdelayerClient != nil {
  109. }
  110. } */