-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from EspressoSystems/jh/fix
Fix isHotShotLive
- Loading branch information
Showing
5 changed files
with
2,451 additions
and
2 deletions.
There are no files selected for viewing
Submodule espresso-sequencer
updated
104 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// This file contains functions that help people interact with light client mock contract. | ||
package lightclientmock | ||
|
||
import ( | ||
"context" | ||
"math/big" | ||
"testing" | ||
|
||
"github.com/ethereum/go-ethereum/accounts/abi/bind" | ||
"github.com/ethereum/go-ethereum/common" | ||
) | ||
|
||
func FreezeL1Height(t *testing.T, client bind.ContractBackend, contractAddress common.Address, txOpts *bind.TransactOpts) error { | ||
mockLightClient, err := NewLightclientmock(contractAddress, client) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
header, err := client.HeaderByNumber(context.Background(), nil) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
_, err = mockLightClient.SetHotShotDownSince(txOpts, header.Number) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func UnfreezeL1Height(t *testing.T, client bind.ContractBackend, contractAddress common.Address, txOpts *bind.TransactOpts) error { | ||
mockLightClient, err := NewLightclientmock(contractAddress, client) | ||
if err != nil { | ||
return err | ||
} | ||
_, err = mockLightClient.SetHotShotUp(txOpts) | ||
|
||
return err | ||
} | ||
|
||
func IsHotShotLive(t *testing.T, client bind.ContractBackend, contractAddress common.Address, threshold uint64) (bool, error) { | ||
mockLightClient, err := NewLightclientmock(contractAddress, client) | ||
if err != nil { | ||
return false, err | ||
} | ||
|
||
header, err := client.HeaderByNumber(context.Background(), nil) | ||
if err != nil { | ||
return false, err | ||
} | ||
|
||
isDown, err := mockLightClient.LagOverEscapeHatchThreshold(nil, header.Number, new(big.Int).SetUint64(threshold)) | ||
if err != nil { | ||
return false, err | ||
} | ||
|
||
return !isDown, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters