-
Notifications
You must be signed in to change notification settings - Fork 6
Add union bridge methods integration tests #288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nathanieliov
wants to merge
6
commits into
main
Choose a base branch
from
add-union-bridge-ITs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,501
−503
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
25a6ebc
- Add UnionBridgeContract and utility constants for union bridge tests
nathanieliov 54da7a1
Update bridge-transaction-parser and rsk-precompiled-abis dependencies
nathanieliov ac09360
Add before Reed ITs for Union Bridge methods
nathanieliov 6a56680
Add integration tests for Union Bridge methods
nathanieliov 1a1ea18
Rename and clean up Union Bridge tests file location
nathanieliov f35164d
WIP
nathanieliov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,24 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| interface BridgeInterface { | ||
| function requestUnionBridgeRbtc(uint256 amountRequested) external returns (int256); | ||
|
|
||
| function releaseUnionBridgeRbtc() external payable returns (int256); | ||
| } | ||
|
|
||
| contract UnionBridgeContract { | ||
| BridgeInterface public bridge = BridgeInterface(0x0000000000000000000000000000000001000006); | ||
|
|
||
| function requestUnionBridgeRbtc(uint256 amountToRequest) external returns (int256) { | ||
| return bridge.requestUnionBridgeRbtc(amountToRequest); | ||
| } | ||
|
|
||
| function releaseUnionBridgeRbtc(uint256 amountToRelease) public payable returns (int256) { | ||
| return bridge.releaseUnionBridgeRbtc{value: amountToRelease}(); | ||
| } | ||
|
|
||
| receive() external payable { } | ||
|
|
||
| fallback() external payable { } | ||
| } |
This file contains hidden or 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
This file contains hidden or 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,76 @@ | ||
| const { btcToWeis } = require("@rsksmart/btc-eth-unit-converter"); | ||
| const { getBridgeStorageIndexFromLongKey } = require("../utils"); | ||
|
|
||
| const UNION_BRIDGE_ADDRESS = '0x0000000000000000000000000000000000000000'; | ||
|
|
||
| // 400 RBTC initial locking cap | ||
| const INITIAL_LOCKING_CAP = btcToWeis(200); | ||
|
|
||
| const LOCKING_CAP_INCREMENTS_MULTIPLIER = 2; | ||
|
|
||
| // Change union bridge contract address authorizer public key | ||
| const CHANGE_UNION_BRIDGE_CONTRACT_ADDRESS_AUTHORIZER_PK = '7880a81a4591568b0e87947e5150fe8e330091678654f3bc661b516f91a5f00a'; | ||
|
|
||
| // Change locking cap authorizers public keys | ||
| const CHANGE_LOCKING_CAP_AUTHORIZERS_PKS = [ | ||
| 'a2221797b4e6655bf39e8290d6db2c75536cf9ffb7f0d2bf4a7360f0b3716e5d' | ||
| ]; | ||
|
|
||
| // Change transfer permissions authorizers public keys | ||
| const CHANGE_TRANSFER_PERMISSIONS_AUTHORIZERS_PKS = [ | ||
| '03918409b6d508f31d72879df0813a6d60d8c74eb91197572c9f3df1da9ae5a5' | ||
| ]; | ||
|
|
||
| const UNION_BRIDGE_EVENTS = { | ||
| UNION_LOCKING_CAP_INCREASED: { | ||
| name: 'union_bridge_locking_cap_increased' | ||
| }, | ||
| UNION_RBTC_REQUESTED: { | ||
| name: 'union_rbtc_requested' | ||
| }, | ||
| UNION_RBTC_RELEASED: { | ||
| name: 'union_rbtc_released' | ||
| }, | ||
| UNION_BRIDGE_TRANSFER_PERMISSIONS_UPDATED: { | ||
| name: 'union_bridge_transfer_permissions_updated' | ||
| } | ||
| }; | ||
|
|
||
| const UNION_BRIDGE_STORAGE_INDICES = { | ||
| UNION_BRIDGE_CONTRACT_ADDRESS: getBridgeStorageIndexFromLongKey('unionBridgeContractAddress'), | ||
| UNION_BRIDGE_LOCKING_CAP: getBridgeStorageIndexFromLongKey('unionBridgeLockingCap'), | ||
| UNION_BRIDGE_INCREASE_LOCKING_CAP_ELECTION: getBridgeStorageIndexFromLongKey('unionBridgeIncreaseLockingCapElection'), | ||
| WEIS_TRANSFERRED_TO_UNION_BRIDGE: getBridgeStorageIndexFromLongKey('weisTransferredToUnionBridge'), | ||
| UNION_BRIDGE_REQUEST_ENABLED: getBridgeStorageIndexFromLongKey('unionBridgeRequestEnabled'), | ||
| UNION_BRIDGE_RELEASE_ENABLED: getBridgeStorageIndexFromLongKey('unionBridgeReleaseEnabled'), | ||
| UNION_BRIDGE_TRANSFER_PERMISSIONS_ELECTION: getBridgeStorageIndexFromLongKey('unionBridgeTransferPermissionsElection') | ||
| } | ||
|
|
||
| const UNION_RESPONSE_CODES = { | ||
| SUCCESS: "0", | ||
| UNAUTHORIZED_CALLER: "-1", | ||
| // Response codes when the value specified is invalid: | ||
| // 1. The requested amount of RBTC, combined with previously requested amounts, exceeds the current locking cap value. | ||
| // 2. The returned amount exceeds the total amount of RBTC previously transferred. | ||
| // 3. The new cap value is less than the current cap or excessive. | ||
| INVALID_VALUE: "-2", | ||
| // Response codes when request or release is disabled: | ||
| REQUEST_DISABLED: "-3", | ||
| RELEASE_DISABLED: "-3", | ||
| // Environment restriction for preventing union bridge address being updated on production | ||
| ENVIRONMENT_DISABLED: "-3", | ||
| GENERIC_ERROR: "-10" | ||
| }; | ||
|
|
||
|
|
||
| module.exports = { | ||
| UNION_BRIDGE_ADDRESS, | ||
| INITIAL_LOCKING_CAP, | ||
| LOCKING_CAP_INCREMENTS_MULTIPLIER, | ||
| CHANGE_UNION_BRIDGE_CONTRACT_ADDRESS_AUTHORIZER_PK, | ||
| CHANGE_LOCKING_CAP_AUTHORIZERS_PKS, | ||
| CHANGE_TRANSFER_PERMISSIONS_AUTHORIZERS_PKS, | ||
| UNION_BRIDGE_EVENTS, | ||
| UNION_BRIDGE_STORAGE_INDICES, | ||
| UNION_RESPONSE_CODES | ||
| }; | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?