This repository has been archived by the owner on Mar 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
/
TestDepositUtils.sol
135 lines (111 loc) · 3.93 KB
/
TestDepositUtils.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
pragma solidity 0.5.17;
import {DepositUtils} from "../../../contracts/deposit/DepositUtils.sol";
import {TestDeposit} from "./TestDeposit.sol";
contract TestDepositUtils is TestDeposit {
constructor() public {
// solium-disable-previous-line no-empty-blocks
}
// Passthroughs to test view and pure functions
function currentBlockDifficulty() public view returns (uint256) {
return self.currentBlockDifficulty();
}
function previousBlockDifficulty() public view returns (uint256) {
return self.previousBlockDifficulty();
}
function evaluateProofDifficulty(bytes memory _bitcoinHeaders) public view {
return self.evaluateProofDifficulty(_bitcoinHeaders);
}
function setPubKey(
bytes32 _signingGroupPubkeyX,
bytes32 _signingGroupPubkeyY
) public {
self.signingGroupPubkeyX = _signingGroupPubkeyX;
self.signingGroupPubkeyY = _signingGroupPubkeyY;
}
function findAndParseFundingOutput(
bytes memory _txOutputVector,
uint8 _fundingOutputIndex
) public view returns (bytes8) {
return self.findAndParseFundingOutput(_txOutputVector, _fundingOutputIndex);
}
function signerFee() public view returns (uint256) {
return self.signerFee();
}
function signerPubkey() public view returns (bytes memory) {
return self.signerPubkey();
}
function signerPKH() public view returns (bytes20) {
return self.signerPKH();
}
function utxoSize() public view returns (uint256) {
return self.utxoSize();
}
function fetchBitcoinPrice() public view returns (uint256) {
return self.fetchBitcoinPrice();
}
function fetchBondAmount() public view returns (uint256) {
return self.fetchBondAmount();
}
function feeRebateTokenHolder() public view returns (address payable) {
return self.feeRebateTokenHolder();
}
function redemptionTeardown() public {
return self.redemptionTeardown();
}
function seizeSignerBonds() public returns (uint256) {
return self.seizeSignerBonds();
}
function distributeFeeRebate() public {
return self.distributeFeeRebate();
}
function pushFundsToKeepGroup(uint256 _ethValue) public returns (bool) {
return self.pushFundsToKeepGroup(_ethValue);
}
function enableWithdrawal(address _withdrawer, uint256 _amount) public {
self.enableWithdrawal(_withdrawer, _amount);
}
}
// Separate contract for testing SPV proofs, as putting this in the main
// TestDepositUtils contract causes it to run out of gas before finishing its
// deploy.
contract TestDepositUtilsSPV is TestDeposit {
constructor() public {
// solium-disable-previous-line no-empty-blocks
}
function setPubKey(
bytes32 _signingGroupPubkeyX,
bytes32 _signingGroupPubkeyY
) public {
self.signingGroupPubkeyX = _signingGroupPubkeyX;
self.signingGroupPubkeyY = _signingGroupPubkeyY;
}
function validateAndParseFundingSPVProof(
bytes4 _txVersion,
bytes memory _txInputVector,
bytes memory _txOutputVector,
bytes4 _txLocktime,
uint8 _fundingOutputIndex,
bytes memory _merkleProof,
uint256 _txIndexInBlock,
bytes memory _bitcoinHeaders
) public view returns (bytes8 _valueBytes, bytes memory _utxoOutpoint){
return self.validateAndParseFundingSPVProof(
_txVersion,
_txInputVector,
_txOutputVector,
_txLocktime,
_fundingOutputIndex,
_merkleProof,
_txIndexInBlock,
_bitcoinHeaders
);
}
function checkProofFromTxId(
bytes32 _bitcoinTxId,
bytes memory _merkleProof,
uint256 _index,
bytes memory _bitcoinHeaders
) public view returns (bytes32) {
self.checkProofFromTxId(_bitcoinTxId, _merkleProof, _index, _bitcoinHeaders);
}
}