Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert changes to tests
  • Loading branch information
mloit committed Apr 26, 2022
commit 84c9885016558cd3b0e6c9d628b34c1ee36f0b04
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation
import XCTest
@testable import web3swift

class ABIEncoderSoliditySha3Test: LocalTestCase {
class ABIEncoderSoliditySha3Test: XCTestCase {

func test_soliditySha3() throws {
var hex = try ABIEncoder.soliditySha3(true).toHexString().addHexPrefix()
Expand Down
2 changes: 1 addition & 1 deletion Tests/web3swiftTests/localTests/DataConversionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import XCTest

// Some base58 test vectors pulled from: https://tools.ietf.org/id/draft-msporny-base58-01.html
// note that one of the return values is incorrect in the reference above, it is corrected here
class DataConversionTests: LocalTestCase {
class DataConversionTests: XCTestCase {
// test an empty input for the base58 decoder & decoder
func testBase58() throws {
let vector = ""
Expand Down
2 changes: 1 addition & 1 deletion Tests/web3swiftTests/localTests/EIP1559BlockTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import BigInt
@testable
import web3swift

class EIP1559BlockTests: LocalTestCase {
class EIP1559BlockTests: XCTestCase {
let uselessBlockPart = (
number: BigUInt(12_965_000),
hash: Data(fromHex: "0xef95f2f1ed3ca60b048b4bf67cde2195961e0bba6f70bcbea9a2c4e133e34b46")!, // "hash":
Expand Down
63 changes: 32 additions & 31 deletions Tests/web3swiftTests/localTests/EIP712Tests.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import XCTest
@testable import web3swift

class EIP712Tests: LocalTestCase {
class EIP712Tests: XCTestCase {
func testWithoutChainId() throws {

let to = EthereumAddress("0x3F06bAAdA68bB997daB03d91DBD0B73e196c5A4d")!

let value = EIP712.UInt256(0)

let amountLinen = EIP712.UInt256("0001000000000000000")//

let function = ABI.Element.Function(
name: "approveAndMint",
inputs: [
Expand All @@ -18,22 +18,22 @@ class EIP712Tests: LocalTestCase {
outputs: [.init(name: "", type: .bool)],
constant: false,
payable: false)

let object = ABI.Element.function(function)

let safeTxData = object.encodeParameters([
EthereumAddress("0x41B5844f4680a8C38fBb695b7F9CFd1F64474a72")! as AnyObject,
amountLinen as AnyObject
])!

let operation: EIP712.UInt8 = 1

let safeTxGas = EIP712.UInt256(250000)

let baseGas = EIP712.UInt256(60000)

let gasPrice = EIP712.UInt256("20000000000")

let gasToken = EthereumAddress("0x0000000000000000000000000000000000000000")!
print(1)
let refundReceiver = EthereumAddress("0x7c07D32e18D6495eFDC487A32F8D20daFBa53A5e")!
Expand Down Expand Up @@ -76,13 +76,13 @@ class EIP712Tests: LocalTestCase {
}

func testWithChainId() throws {

let to = EthereumAddress("0x3F06bAAdA68bB997daB03d91DBD0B73e196c5A4d")!

let value = EIP712.UInt256(0)

let amount = EIP712.UInt256("0001000000000000000")

let function = ABI.Element.Function(
name: "approveAndMint",
inputs: [
Expand All @@ -91,28 +91,28 @@ class EIP712Tests: LocalTestCase {
outputs: [.init(name: "", type: .bool)],
constant: false,
payable: false)

let object = ABI.Element.function(function)

let safeTxData = object.encodeParameters([
EthereumAddress("0x41B5844f4680a8C38fBb695b7F9CFd1F64474a72")! as AnyObject,
amount as AnyObject
])!

let operation: EIP712.UInt8 = 1

let safeTxGas = EIP712.UInt256(250000)

let baseGas = EIP712.UInt256(60000)

let gasPrice = EIP712.UInt256("20000000000")

let gasToken = EthereumAddress("0x0000000000000000000000000000000000000000")!

let refundReceiver = EthereumAddress("0x7c07D32e18D6495eFDC487A32F8D20daFBa53A5e")!

let nonce: EIP712.UInt256 = .init(0)

let safeTX = SafeTx(
to: to,
value: value,
Expand All @@ -124,24 +124,25 @@ class EIP712Tests: LocalTestCase {
gasToken: gasToken,
refundReceiver: refundReceiver,
nonce: nonce)

let mnemonic = "normal dune pole key case cradle unfold require tornado mercy hospital buyer"
let keystore = try! BIP32Keystore(mnemonics: mnemonic, password: "", mnemonicsPassword: "")!

let verifyingContract = EthereumAddress("0x76106814dc6150b0fe510fbda4d2d877ac221270")!

let account = keystore.addresses?[0]
let password = ""
let chainId: EIP712.UInt256? = EIP712.UInt256(42)

let signature = try Web3Signer.signEIP712(
safeTx: safeTX,
keystore: keystore,
verifyingContract: verifyingContract,
account: account!,
password: password,
chainId: chainId)

XCTAssertEqual(signature.toHexString(), "f1f423cb23efad5035d4fb95c19cfcd46d4091f2bd924680b88c4f9edfa1fb3a4ce5fc5d169f354e3b464f45a425ed3f6203af06afbacdc5c8224a300ce9e6b21b")
}
}

44 changes: 0 additions & 44 deletions Tests/web3swiftTests/localTests/LocalTestCase.swift

This file was deleted.

3 changes: 1 addition & 2 deletions Tests/web3swiftTests/localTests/LocalTests.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
"RemoteParsingTests",
"RemoteTests",
"ST20AndSecurityTokenTests",
"WebsocketTests",
"LocalTestCase"
"WebsocketTests"
],
"target" : {
"containerPath" : "container:web3swift.xcodeproj",
Expand Down
129 changes: 68 additions & 61 deletions Tests/web3swiftTests/localTests/web3swiftAdvancedABIv2Tests.swift

Large diffs are not rendered by default.

Loading