Skip to content

Commit ccf351f

Browse files
committed
chore: update LocalFiat tests for sending amount validation
Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent ab957e0 commit ccf351f

1 file changed

Lines changed: 56 additions & 53 deletions

File tree

  • services/opencode/src/test/kotlin/com/getcode/opencode/model/financial

services/opencode/src/test/kotlin/com/getcode/opencode/model/financial/LocalFiatTests.kt

Lines changed: 56 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -84,62 +84,67 @@ class LocalFiatTests {
8484
println(output)
8585

8686
val expectedOutput = """
87-
10000000000 5001092401997 $5.00
88-
10000000000 10004379663394 $10.00
89-
10000000000 100441080923772 $100.00
90-
10000000000 511295760602584 $500.00
91-
10000000000 1046604099690267 $1,000.00
92-
100000000000 5001052911980 $5.00
93-
100000000000 10004300648691 $10.00
94-
100000000000 100440284483693 $100.00
95-
100000000000 511291632270217 $500.00
96-
100000000000 1046595446081380 $1,000.00
97-
1000000000000 5000658028967 $5.00
98-
1000000000000 10003510535997 $10.00
99-
1000000000000 100432320431767 $100.00
100-
1000000000000 511250350821238 $500.00
101-
1000000000000 1046508914111068 $1,000.00
102-
10000000000000 4996710913709 $5.00
103-
10000000000000 9995612841801 $10.00
104-
10000000000000 100352714788750 $100.00
105-
10000000000000 510837723741344 $500.00
106-
10000000000000 1045644006120180 $1,000.00
107-
100000000000000 4957410747532 $5.00
108-
100000000000000 9916978171984 $10.00
109-
100000000000000 99560135637918 $100.00
110-
100000000000000 506730134317242 $500.00
111-
100000000000000 1037035954468485 $1,000.00
112-
1000000000000000 4581018238122 $5.00
113-
1000000000000000 9163878032451 $10.00
114-
1000000000000000 91971957711638 $100.00
115-
1000000000000000 467464270426932 $500.00
116-
1000000000000000 954919469210810 $1,000.00
117-
10000000000000000 2079970815228 $5.00
118-
10000000000000000 4160321190168 $10.00
119-
10000000000000000 41671690967489 $100.00
120-
10000000000000000 209898607695880 $500.00
121-
10000000000000000 423734428251854 $1,000.00
122-
100000000000000000 775257916 $5.00
123-
100000000000000000 1550515885 $10.00
124-
100000000000000000 15505168342 $100.00
125-
100000000000000000 77526052595 $500.00
126-
100000000000000000 155052632401 $1,000.00
87+
1000000 5000658048209 $5.00
88+
1000000 10003510574497 $10.00
89+
1000000 100432320819833 $100.00
90+
1000000 511250352832763 $500.00
91+
1000000 1046508918327512 $1,000.00
92+
10000000 4996712835333 $5.00
93+
10000000 9995616686734 $10.00
94+
10000000 100352753544040 $100.00
95+
10000000 510837924622184 $500.00
96+
10000000 1045644427178339 $1,000.00
97+
100000000 4957600405006 $5.00
98+
100000000 9917357651988 $10.00
99+
100000000 99563960395722 $100.00
100+
100000000 506749953488320 $500.00
101+
100000000 1037077480269837 $1,000.00
102+
1000000000 4597708679970 $5.00
103+
1000000000 9197272362330 $10.00
104+
1000000000 92308339982136 $100.00
105+
1000000000 469202608629475 $500.00
106+
1000000000 958548327430505 $1,000.00
107+
10000000000 2663887739947 $5.00
108+
10000000000 5328398095088 $10.00
109+
10000000000 53396384541881 $100.00
110+
10000000000 269518606881772 $500.00
111+
10000000000 545563645468226 $1,000.00
112+
100000000000 511690414900 $5.00
113+
100000000000 1023403797655 $10.00
114+
100000000000 10238174542457 $100.00
115+
100000000000 51283066886112 $500.00
116+
100000000000 102797869580410 $1,000.00
117+
1000000000000 56358788487 $5.00
118+
1000000000000 112717855594 $10.00
119+
1000000000000 1127228710628 $100.00
120+
1000000000000 5637258461866 $500.00
121+
1000000000000 11277305850369 $1,000.00
122+
10000000000000 5693625634 $5.00
123+
10000000000000 11387254111 $10.00
124+
10000000000000 113873052964 $100.00
125+
10000000000000 569376639559 $500.00
126+
10000000000000 1138781717663 $1,000.00
127+
100000000000000 569946546 $5.00
128+
100000000000000 1139893121 $10.00
129+
100000000000000 11398936344 $100.00
130+
100000000000000 56994795699 $500.00
131+
100000000000000 113989876341 $1,000.00
127132
""".trimIndent()
128133

129134
val actualLines = output.lines()
130135
val expectedLines = expectedOutput.lines()
131136

132-
// assertEquals(expectedLines.size, actualLines.size)
133-
//
134-
// for (i in actualLines.indices) {
135-
// val actualParts = actualLines[i].split("\\s+".toRegex()).filter { it.isNotEmpty() }
136-
// val expectedParts = expectedLines[i].split("\\s+".toRegex()).filter { it.isNotEmpty() }
137-
//
138-
// assertEquals(expectedParts[0], actualParts[0], "Column 1 mismatch on line $i")
139-
// val diff = (expectedParts[1].toLong() - actualParts[1].toLong()).let { if (it < 0) -it else it }
140-
// assertTrue(diff <= 1, "Column 2 is not within 1 on line $i")
141-
// assertEquals(expectedParts[2], actualParts[2], "Column 3 mismatch on line $i")
142-
// }
137+
assertEquals(expectedLines.size, actualLines.size)
138+
139+
for (i in actualLines.indices) {
140+
val actualParts = actualLines[i].split("\\s+".toRegex()).filter { it.isNotEmpty() }
141+
val expectedParts = expectedLines[i].split("\\s+".toRegex()).filter { it.isNotEmpty() }
142+
143+
assertEquals(expectedParts[0], actualParts[0], "Column 1 mismatch on line $i")
144+
val diff = (expectedParts[1].toLong() - actualParts[1].toLong()).let { if (it < 0) -it else it }
145+
assertTrue(diff <= 1, "Column 2 is not within 1 on line $i")
146+
assertEquals(expectedParts[2], actualParts[2], "Column 3 mismatch on line $i")
147+
}
143148
}
144149

145150
@Test
@@ -150,7 +155,6 @@ class LocalFiatTests {
150155
val quarks = 1_000_000_000_000L
151156

152157
val output = buildString {
153-
var index = 0
154158
var volume = startVol
155159
while (volume <= endVol) {
156160
val updatedTokenOnChain = token.copy(
@@ -176,7 +180,6 @@ class LocalFiatTests {
176180
appendLine(nativeAmountsForExchangedQuarks)
177181

178182
volume *= 10
179-
index += 1
180183
}
181184
}.trim()
182185

0 commit comments

Comments
 (0)