|
1 | 1 | using System.Numerics;
|
2 |
| -using System.Reflection; |
3 | 2 |
|
4 | 3 | namespace Thirdweb.Tests.RPC;
|
5 | 4 |
|
@@ -34,24 +33,6 @@ public async Task TestTimeout()
|
34 | 33 | _ = await Assert.ThrowsAsync<TimeoutException>(async () => await rpc.SendRequestAsync<string>("eth_chainId"));
|
35 | 34 | }
|
36 | 35 |
|
37 |
| - [Fact(Timeout = 120000)] |
38 |
| - public async Task TestBatch() |
39 |
| - { |
40 |
| - var client = ThirdwebClient.Create(secretKey: this.SecretKey); |
41 |
| - var rpc = ThirdwebRPC.GetRpcInstance(client, 1); |
42 |
| - var req = rpc.SendRequestAsync<string>("eth_blockNumber"); |
43 |
| - _ = await rpc.SendRequestAsync<string>("eth_chainId"); |
44 |
| - var blockNumberTasks = new List<Task<string>>(); |
45 |
| - for (var i = 0; i < 100; i++) |
46 |
| - { |
47 |
| - blockNumberTasks.Add(rpc.SendRequestAsync<string>("eth_blockNumber")); |
48 |
| - } |
49 |
| - var results = await Task.WhenAll(blockNumberTasks); |
50 |
| - Assert.Equal(100, results.Length); |
51 |
| - Assert.All(results, result => Assert.StartsWith("0x", result)); |
52 |
| - Assert.All(results, result => Assert.Equal(results[0], result)); |
53 |
| - } |
54 |
| - |
55 | 36 | [Fact(Timeout = 120000)]
|
56 | 37 | public async Task TestDeserialization()
|
57 | 38 | {
|
@@ -95,65 +76,8 @@ public async Task TestCache()
|
95 | 76 | var client = ThirdwebClient.Create(secretKey: this.SecretKey);
|
96 | 77 | var rpc = ThirdwebRPC.GetRpcInstance(client, 1);
|
97 | 78 | var blockNumber1 = await rpc.SendRequestAsync<string>("eth_blockNumber");
|
98 |
| - await Task.Delay(100); |
| 79 | + await ThirdwebTask.Delay(100); |
99 | 80 | var blockNumber2 = await rpc.SendRequestAsync<string>("eth_blockNumber");
|
100 | 81 | Assert.Equal(blockNumber1, blockNumber2);
|
101 | 82 | }
|
102 |
| - |
103 |
| - [Fact(Timeout = 120000)] |
104 |
| - public async Task TestBatchSizeLimit() |
105 |
| - { |
106 |
| - var client = ThirdwebClient.Create(secretKey: this.SecretKey); |
107 |
| - var rpc = ThirdwebRPC.GetRpcInstance(client, 1); |
108 |
| - var blockNumberTasks = new List<Task<string>>(); |
109 |
| - for (var i = 0; i < 101; i++) |
110 |
| - { |
111 |
| - blockNumberTasks.Add(rpc.SendRequestAsync<string>("eth_blockNumber")); |
112 |
| - } |
113 |
| - var results = await Task.WhenAll(blockNumberTasks); |
114 |
| - Assert.Equal(101, results.Length); |
115 |
| - Assert.All(results, result => Assert.StartsWith("0x", result)); |
116 |
| - } |
117 |
| - |
118 |
| - [Fact(Timeout = 120000)] |
119 |
| - public void Timer_StartsAndStops() |
120 |
| - { |
121 |
| - var timer = new ThirdwebRPCTimer(TimeSpan.FromMilliseconds(100)); |
122 |
| - timer.Start(); |
123 |
| - Assert.True(IsTimerRunning(timer)); |
124 |
| - |
125 |
| - timer.Stop(); |
126 |
| - Assert.False(IsTimerRunning(timer)); |
127 |
| - } |
128 |
| - |
129 |
| - [Fact(Timeout = 120000)] |
130 |
| - public async Task Timer_ElapsedEventFires() |
131 |
| - { |
132 |
| - var timer = new ThirdwebRPCTimer(TimeSpan.FromMilliseconds(100)); |
133 |
| - var eventFired = false; |
134 |
| - |
135 |
| - timer.Elapsed += () => eventFired = true; |
136 |
| - timer.Start(); |
137 |
| - |
138 |
| - await Task.Delay(200); // Wait for the timer to elapse at least once |
139 |
| - Assert.True(eventFired); |
140 |
| - |
141 |
| - timer.Stop(); |
142 |
| - } |
143 |
| - |
144 |
| - [Fact(Timeout = 120000)] |
145 |
| - public void Timer_DisposeStopsTimer() |
146 |
| - { |
147 |
| - var timer = new ThirdwebRPCTimer(TimeSpan.FromMilliseconds(100)); |
148 |
| - timer.Start(); |
149 |
| - timer.Dispose(); |
150 |
| - Assert.False(IsTimerRunning(timer)); |
151 |
| - } |
152 |
| - |
153 |
| - private static bool IsTimerRunning(ThirdwebRPCTimer timer) |
154 |
| - { |
155 |
| - var fieldInfo = typeof(ThirdwebRPCTimer).GetField("_isRunning", BindingFlags.NonPublic | BindingFlags.Instance) ?? throw new InvalidOperationException("The field '_isRunning' was not found."); |
156 |
| - var value = fieldInfo.GetValue(timer); |
157 |
| - return value == null ? throw new InvalidOperationException("The field '_isRunning' value is null.") : (bool)value; |
158 |
| - } |
159 | 83 | }
|
0 commit comments