Skip to content
Merged
Changes from all commits
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
8 changes: 5 additions & 3 deletions tests/Neo.VM.Tests/Helpers/RandomHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
// modifications are permitted.

using System;
using System.Threading;

namespace Neo.Test.Helpers;

public class RandomHelper
{
private const string _randchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
private static readonly Random _rand = new();

private static readonly ThreadLocal<Random> _rand = new(() => new Random());

/// <summary>
/// Get random buffer
Expand All @@ -26,7 +28,7 @@ public class RandomHelper
public static byte[] RandBuffer(int length)
{
var buffer = new byte[length];
_rand.NextBytes(buffer);
_rand.Value.NextBytes(buffer);
return buffer;
}

Expand All @@ -41,7 +43,7 @@ public static string RandString(int length)

for (int i = 0; i < stringChars.Length; i++)
{
stringChars[i] = _randchars[_rand.Next(_randchars.Length)];
stringChars[i] = _randchars[_rand.Value.Next(_randchars.Length)];
}

return new string(stringChars);
Expand Down