@@ -11,12 +11,12 @@ import BigInt
11
11
@testable import web3swift
12
12
13
13
class UncategorizedTests : LocalTestCase {
14
- func testBitFunctions ( ) throws {
15
- let data = Data ( [ 0xf0 , 0x02 , 0x03 ] )
14
+ func testBitFunctions( ) throws {
15
+ let data = Data ( [ 0xF0 , 0x02 , 0x03 ] )
16
16
let firstBit = data. bitsInRange ( 0 , 1 )
17
17
XCTAssert ( firstBit == 1 )
18
18
let first4bits = data. bitsInRange ( 0 , 4 )
19
- XCTAssert ( first4bits == 0x0f )
19
+ XCTAssert ( first4bits == 0x0F )
20
20
}
21
21
22
22
func testCombiningPublicKeys( ) throws {
@@ -59,29 +59,28 @@ class UncategorizedTests: LocalTestCase {
59
59
XCTAssertEqual ( " " . split ( every: 3 ) , [ ] )
60
60
61
61
XCTAssertEqual ( " abcdefgh " . split ( every: 1 ) , [ " a " , " b " , " c " , " d " , " e " , " f " , " g " , " h " ] )
62
- XCTAssertEqual ( " abcdefgh " . split ( every: 1 , backwards: true ) , [ " a " , " b " , " c " , " d " , " e " , " f " , " g " , " h " ] ) // should be the same as from the front
62
+ XCTAssertEqual ( " abcdefgh " . split ( every: 1 , backwards: true ) ,
63
+ [ " a " , " b " , " c " , " d " , " e " , " f " , " g " , " h " ] ) // should be the same as from the front
63
64
}
64
65
65
66
func testBloom( ) throws {
66
67
let positive = [
67
- " testtest " ,
68
- " test " ,
69
- " hallo " ,
70
- " other "
71
- ]
68
+ " testtest " ,
69
+ " test " ,
70
+ " hallo " ,
71
+ " other "
72
+ ]
72
73
let negative = [
73
- " tes " ,
74
- " lo "
75
- ]
74
+ " tes " ,
75
+ " lo "
76
+ ]
76
77
var bloom = EthereumBloomFilter ( )
77
78
for str in positive {
78
79
let data = str. data ( using: . utf8) !
79
80
let oldBytes = bloom. bytes
80
81
bloom. add ( BigUInt ( data) )
81
82
let newBytes = bloom. bytes
82
- if newBytes != oldBytes {
83
-
84
- }
83
+ if newBytes != oldBytes { }
85
84
}
86
85
for str in positive {
87
86
let data = str. data ( using: . utf8) !
@@ -98,19 +97,19 @@ class UncategorizedTests: LocalTestCase {
98
97
XCTAssert ( privKey != nil , " Failed to create new private key " )
99
98
}
100
99
101
- func testIBANcreation( ) throws {
102
- let iban = " XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS "
103
- let native = Web3 . Utils. Iban ( iban)
104
- XCTAssert ( native != nil )
105
- let expectedAddress = " 0x00c5496aEe77C1bA1f0854206A26DdA82a81D6D8 "
106
- let createdAddress = native? . toEthereumAddress ( ) ? . address
107
- XCTAssert ( createdAddress == expectedAddress)
108
-
109
- let address = EthereumAddress ( " 0x03c5496aee77c1ba1f0854206a26dda82a81d6d8 " ) !
110
- let fromAddress = Web3 . Utils. Iban ( address)
111
- let ibn = fromAddress? . iban
112
- XCTAssert ( ibn == " XE83FUTTUNPK7WZJSGGCWVEBARQWQ8YML4 " )
113
- }
100
+ // func testIBANcreation() throws {
101
+ // let iban = "XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS"
102
+ // let native = Web3.Utils.Iban(iban)
103
+ // XCTAssert(native != nil)
104
+ // let expectedAddress = "0x00c5496aEe77C1bA1f0854206A26DdA82a81D6D8"
105
+ // let createdAddress = native?.toEthereumAddress()?.address
106
+ // XCTAssert(createdAddress == expectedAddress)
107
+
108
+ // let address = EthereumAddress("0x03c5496aee77c1ba1f0854206a26dda82a81d6d8")!
109
+ // let fromAddress = Web3.Utils.Iban(address)
110
+ // let ibn = fromAddress?.iban
111
+ // XCTAssert(ibn == "XE83FUTTUNPK7WZJSGGCWVEBARQWQ8YML4")
112
+ // }
114
113
115
114
// func testGenericRPCresponse() throws {
116
115
// let hex = "0x1"
@@ -120,11 +119,15 @@ class UncategorizedTests: LocalTestCase {
120
119
// }
121
120
122
121
func testPublicMappingsAccess( ) async throws {
123
- let bytecode = Data ( hex: " 0x608060405234801561001057600080fd5b5061023d806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063365b98b2146100465780635e79ab6014610076578063bff1f9e1146100a6575b600080fd5b610060600480360381019061005b919061014a565b6100c4565b60405161006d9190610182565b60405180910390f35b610090600480360381019061008b9190610121565b6100ce565b60405161009d9190610182565b60405180910390f35b6100ae6100ee565b6040516100bb9190610182565b60405180910390f35b6000819050919050565b60008173ffffffffffffffffffffffffffffffffffffffff169050919050565b60006064905090565b600081359050610106816101d9565b92915050565b60008135905061011b816101f0565b92915050565b60006020828403121561013357600080fd5b6000610141848285016100f7565b91505092915050565b60006020828403121561015c57600080fd5b600061016a8482850161010c565b91505092915050565b61017c816101cf565b82525050565b60006020820190506101976000830184610173565b92915050565b60006101a8826101af565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6101e28161019d565b81146101ed57600080fd5b50565b6101f9816101cf565b811461020457600080fd5b5056fea26469706673582212207373b0db986284793522a82bff7bf03e30323defa94e6d25f7141e7d63e1ee0564736f6c63430008040033 " )
124
- let jsonString = " [{ \" constant \" :true, \" inputs \" :[{ \" name \" : \" \" , \" type \" : \" uint256 \" }], \" name \" : \" users \" , \" outputs \" :[{ \" name \" : \" name \" , \" type \" : \" uint256 \" }], \" payable \" :false, \" stateMutability \" : \" view \" , \" type \" : \" function \" },{ \" constant \" :true, \" inputs \" :[{ \" name \" : \" \" , \" type \" : \" address \" }], \" name \" : \" userDeviceCount \" , \" outputs \" :[{ \" name \" : \" \" , \" type \" : \" uint256 \" }], \" payable \" :false, \" stateMutability \" : \" view \" , \" type \" : \" function \" },{ \" constant \" :true, \" inputs \" :[], \" name \" : \" totalUsers \" , \" outputs \" :[{ \" name \" : \" \" , \" type \" : \" uint256 \" }], \" payable \" :false, \" stateMutability \" : \" view \" , \" type \" : \" function \" }] "
122
+ let bytecode =
123
+ Data (
124
+ hex: " 0x608060405234801561001057600080fd5b5061023d806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063365b98b2146100465780635e79ab6014610076578063bff1f9e1146100a6575b600080fd5b610060600480360381019061005b919061014a565b6100c4565b60405161006d9190610182565b60405180910390f35b610090600480360381019061008b9190610121565b6100ce565b60405161009d9190610182565b60405180910390f35b6100ae6100ee565b6040516100bb9190610182565b60405180910390f35b6000819050919050565b60008173ffffffffffffffffffffffffffffffffffffffff169050919050565b60006064905090565b600081359050610106816101d9565b92915050565b60008135905061011b816101f0565b92915050565b60006020828403121561013357600080fd5b6000610141848285016100f7565b91505092915050565b60006020828403121561015c57600080fd5b600061016a8482850161010c565b91505092915050565b61017c816101cf565b82525050565b60006020820190506101976000830184610173565b92915050565b60006101a8826101af565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6101e28161019d565b81146101ed57600080fd5b50565b6101f9816101cf565b811461020457600080fd5b5056fea26469706673582212207373b0db986284793522a82bff7bf03e30323defa94e6d25f7141e7d63e1ee0564736f6c63430008040033 "
125
+ )
126
+ let jsonString =
127
+ " [{ \" constant \" :true, \" inputs \" :[{ \" name \" : \" \" , \" type \" : \" uint256 \" }], \" name \" : \" users \" , \" outputs \" :[{ \" name \" : \" name \" , \" type \" : \" uint256 \" }], \" payable \" :false, \" stateMutability \" : \" view \" , \" type \" : \" function \" },{ \" constant \" :true, \" inputs \" :[{ \" name \" : \" \" , \" type \" : \" address \" }], \" name \" : \" userDeviceCount \" , \" outputs \" :[{ \" name \" : \" \" , \" type \" : \" uint256 \" }], \" payable \" :false, \" stateMutability \" : \" view \" , \" type \" : \" function \" },{ \" constant \" :true, \" inputs \" :[], \" name \" : \" totalUsers \" , \" outputs \" :[{ \" name \" : \" \" , \" type \" : \" uint256 \" }], \" payable \" :false, \" stateMutability \" : \" view \" , \" type \" : \" function \" }] "
125
128
let receipt = try await deployContract ( bytecode: bytecode, abiString: jsonString)
126
129
let web3 = try await Web3 . new ( LocalTestCase . url)
127
- guard let addr = receipt. contractAddress else { return XCTFail ( ) }
130
+ guard let addr = receipt. contractAddress else { return XCTFail ( ) }
128
131
let contract = web3. contract ( jsonString, at: receipt. contractAddress!, abiVersion: 2 )
129
132
130
133
let userDeviceCount = try await contract!
0 commit comments