@@ -186,6 +186,7 @@ public async Task GenerateRandomNumberTest()
186186 // Generate 100 random number
187187 randomNumberCount = 10 ;
188188 maxValue = 100 ;
189+ hash = "Test" ;
189190 result = await RandomContractStub . GenerateRandomNumber . SendAsync ( new GenerateRandomNumberInput
190191 {
191192 Hash = hash ,
@@ -213,6 +214,17 @@ public async Task GenerateRandomNumberTest()
213214 randomSet . Add ( randomNumber ) ;
214215 }
215216
217+ // Generate random number with same hash and expect an exception
218+ result = await RandomContractStub . GenerateRandomNumber . SendWithExceptionAsync ( new GenerateRandomNumberInput
219+ {
220+ Hash = hash ,
221+ RandomNumberCount = randomNumberCount ,
222+ MaxValue = maxValue
223+ } ) ;
224+ result . TransactionResult . Status . ShouldBe ( TransactionResultStatus . Failed ) ;
225+ result . TransactionResult . Error . ShouldContain ( "Random number already generated" ) ;
226+
227+ hash = "OtherHash" ;
216228 // Generate random number with invalid max value and expect an exception
217229 result = await RandomContractStub . GenerateRandomNumber . SendWithExceptionAsync ( new GenerateRandomNumberInput
218230 {
@@ -246,6 +258,15 @@ public async Task GenerateRandomNumberTest()
246258 {
247259 Hash = hash ,
248260 RandomNumberCount = maxRandomNumberCount + 1 ,
261+ MaxValue = maxValueLimit
262+ } ) ;
263+ result . TransactionResult . Status . ShouldBe ( TransactionResultStatus . Failed ) ;
264+ result . TransactionResult . Error . ShouldContain ( "Invalid random number count" ) ;
265+
266+ result = await RandomContractStub . GenerateRandomNumber . SendWithExceptionAsync ( new GenerateRandomNumberInput
267+ {
268+ Hash = hash ,
269+ RandomNumberCount = maxValue + 1 ,
249270 MaxValue = maxValue
250271 } ) ;
251272 result . TransactionResult . Status . ShouldBe ( TransactionResultStatus . Failed ) ;
0 commit comments