@@ -12,7 +12,7 @@ import {
1212import { Contract } from "ethers" ;
1313import { TokenContract } from "./types" ;
1414import { AuctionDeployer } from "./AuctionDeployer" ;
15- import { ZERO_ADDRESS , LOG_PREFIXES , ERROR_MESSAGES , TYPES , TYPE_FIELD } from "./constants" ;
15+ import { ZERO_ADDRESS , LOG_PREFIXES , ERROR_MESSAGES , TYPES , ONE_MILLION } from "./constants" ;
1616import { CheckpointStruct } from "../../../typechain-types/out/Auction" ;
1717import { resolveTokenAddress } from "./utils" ;
1818import hre from "hardhat" ;
@@ -91,12 +91,12 @@ export class AssertionEngine {
9191 // Percentage: convert to ratio and apply to expected (e.g., "5%" -> 5% of expected)
9292 const percentage = parseFloat ( varianceStr . slice ( 0 , - 1 ) ) ;
9393 const ratio = percentage / 100 ;
94- varianceAmount = ( expected * BigInt ( Math . floor ( ratio * 1000000 ) ) ) / 1000000n ;
94+ varianceAmount = ( expected * BigInt ( Math . floor ( ratio * ONE_MILLION ) ) ) / BigInt ( ONE_MILLION ) ;
9595 } else {
9696 if ( varianceStr . includes ( "." ) ) {
9797 const numericValue = parseFloat ( varianceStr ) ;
9898 // Ratio: treat as percentage in decimal form (e.g., "0.05" -> 5% of expected)
99- varianceAmount = ( expected * BigInt ( Math . floor ( numericValue * 1000000 ) ) ) / 1000000n ;
99+ varianceAmount = ( expected * BigInt ( Math . floor ( numericValue * ONE_MILLION ) ) ) / BigInt ( ONE_MILLION ) ;
100100 } else {
101101 // Raw amount: use as absolute tolerance (e.g., "100000000000000000")
102102 varianceAmount = BigInt ( varianceStr ) ;
@@ -437,13 +437,7 @@ export class AssertionEngine {
437437 return true ; // No args to check, just event name match is enough
438438 }
439439 for ( const [ , expectedValue ] of Object . entries ( expectedArgs ) ) {
440- let contains = false ;
441- softMatchLoop: for ( let i = 0 ; i < actualArgs . length ; i ++ ) {
442- if ( actualArgs [ i ] . toString ( ) == expectedValue . toString ( ) ) {
443- contains = true ;
444- break softMatchLoop;
445- }
446- }
440+ let contains = actualArgs . some ( ( value : any ) => value == expectedValue ) . length > 0 ;
447441 if ( ! contains ) {
448442 return false ;
449443 }
@@ -479,6 +473,12 @@ export class AssertionEngine {
479473 * @returns BidderState object containing address, tokenBalance, and currencyBalance
480474 */
481475 async getBidderState ( bidderAddress : Address ) : Promise < BidderState > {
476+ if ( this . token == undefined ) {
477+ throw new Error ( ERROR_MESSAGES . TOKEN_UNSET ) ;
478+ }
479+ if ( this . currency === undefined ) {
480+ throw new Error ( ERROR_MESSAGES . CURRENCY_UNSET ) ;
481+ }
482482 const tokenBalance = this . token ? await this . token . balanceOf ( bidderAddress ) : 0n ;
483483 const currencyBalance = this . currency ? await this . currency . balanceOf ( bidderAddress ) : 0n ;
484484
0 commit comments