52 lines
928 B
Go
52 lines
928 B
Go
package scenarios
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestAllScenariosRegistered(t *testing.T) {
|
|
expected := []string{"S1", "S2", "S3", "S4", "S5", "S6", "S7"}
|
|
for _, id := range expected {
|
|
if _, ok := registry[id]; !ok {
|
|
t.Errorf("scenario %s not registered", id)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestMintNameFormat(t *testing.T) {
|
|
name := mintName(30000001, 3)
|
|
if !strings.HasPrefix(name, "loadtest_mint_") {
|
|
t.Errorf("name %q must start with loadtest_mint_", name)
|
|
}
|
|
if !strings.Contains(name, "30000001") {
|
|
t.Errorf("name %q must contain user id", name)
|
|
}
|
|
}
|
|
|
|
func mintName(uid int64, round int) string {
|
|
return "loadtest_mint_" + itoa(uid) + "_round" + itoa(int64(round))
|
|
}
|
|
|
|
func itoa(n int64) string {
|
|
if n == 0 {
|
|
return "0"
|
|
}
|
|
neg := n < 0
|
|
if neg {
|
|
n = -n
|
|
}
|
|
var buf [20]byte
|
|
i := len(buf)
|
|
for n > 0 {
|
|
i--
|
|
buf[i] = byte('0' + n%10)
|
|
n /= 10
|
|
}
|
|
if neg {
|
|
i--
|
|
buf[i] = '-'
|
|
}
|
|
return string(buf[i:])
|
|
}
|