@@ -89,12 +89,14 @@ class web3swiftTests: XCTestCase {
89
89
}
90
90
91
91
func testCombiningPublicKeys( ) {
92
- let priv1 = Data . randomBytes ( length : 32 ) !
92
+ let priv1 = Data ( repeating : 0x01 , count : 32 )
93
93
let pub1 = Web3 . Utils. privateToPublic ( priv1, compressed: true ) !
94
- let priv2 = Data . randomBytes ( length : 32 ) !
94
+ let priv2 = Data ( repeating : 0x02 , count : 32 )
95
95
let pub2 = Web3 . Utils. privateToPublic ( priv2, compressed: true ) !
96
96
let combined = SECP256K1 . combineSerializedPublicKeys ( keys: [ pub1, pub2] , outputCompressed: true )
97
- XCTAssert ( combined != nil )
97
+ let compinedPriv = Data ( repeating: 0x03 , count: 32 )
98
+ let compinedPub = Web3 . Utils. privateToPublic ( compinedPriv, compressed: true )
99
+ XCTAssert ( compinedPub == combined)
98
100
}
99
101
100
102
func testBIP39 ( ) {
@@ -2055,14 +2057,25 @@ class web3swiftTests: XCTestCase {
2055
2057
switch result {
2056
2058
case . success( let res) :
2057
2059
guard let signer = res [ " signer " ] ! as? EthereumAddress else { return XCTFail ( ) }
2060
+ print ( signer)
2058
2061
XCTAssert ( signer == expectedAddress)
2059
2062
case . failure( let error) :
2060
2063
print ( error)
2061
2064
XCTFail ( )
2062
2065
}
2063
2066
}
2064
2067
2065
-
2068
+ func testUserCaseEventParsing( ) {
2069
+ let contractAddress = EthereumAddress ( " 0x7ff546aaccd379d2d1f241e1d29cdd61d4d50778 " )
2070
+ let jsonString = " [{ \" constant \" :false, \" inputs \" :[{ \" name \" : \" _id \" , \" type \" : \" string \" }], \" name \" : \" deposit \" , \" outputs \" :[], \" payable \" :true, \" stateMutability \" : \" payable \" , \" type \" : \" function \" },{ \" anonymous \" :false, \" inputs \" :[{ \" indexed \" :true, \" name \" : \" _from \" , \" type \" : \" address \" },{ \" indexed \" :false, \" name \" : \" _id \" , \" type \" : \" string \" },{ \" indexed \" :true, \" name \" : \" _value \" , \" type \" : \" uint256 \" }], \" name \" : \" Deposit \" , \" type \" : \" event \" }] "
2071
+ let web3 = Web3 . InfuraRinkebyWeb3 ( )
2072
+ let contract = web3. contract ( jsonString, at: contractAddress, abiVersion: 2 )
2073
+ guard let eventParser = contract? . createEventParser ( " Deposit " , filter: nil ) else { return XCTFail ( ) }
2074
+ let present = eventParser. parseBlockByNumber ( UInt64 ( 2138657 ) )
2075
+ guard case . success( let pres) = present else { return XCTFail ( ) }
2076
+ print ( pres)
2077
+ XCTAssert ( pres. count == 1 )
2078
+ }
2066
2079
2067
2080
func testPerformanceExample( ) {
2068
2081
// This is an example of a performance test case.
0 commit comments