()
| 187 | ) |
| 188 | |
| 189 | func setup() { |
| 190 | const minNoFile uint64 = 4096 |
| 191 | var ( |
| 192 | err error |
| 193 | lmt syscall.Rlimit |
| 194 | ) |
| 195 | |
| 196 | if testingDataDir, err = ioutil.TempDir("", "CovenantSQL"); err != nil { |
| 197 | panic(err) |
| 198 | } |
| 199 | |
| 200 | rand.Seed(time.Now().UnixNano()) |
| 201 | |
| 202 | if runtime.GOOS == "linux" { |
| 203 | // Set NOFILE limit |
| 204 | if err = syscall.Getrlimit(syscall.RLIMIT_NOFILE, &lmt); err != nil { |
| 205 | panic(err) |
| 206 | } |
| 207 | if lmt.Max < minNoFile { |
| 208 | panic("insufficient max RLIMIT_NOFILE") |
| 209 | } |
| 210 | lmt.Cur = lmt.Max |
| 211 | if err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &lmt); err != nil { |
| 212 | panic(err) |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | // Initialze kms |
| 217 | testingNonceDifficulty = 2 |
| 218 | testingPrivateKeyFile = path.Join(testingDataDir, "private.key") |
| 219 | testingPublicKeyStoreFile = path.Join(testingDataDir, "public.keystore") |
| 220 | if testingPrivateKey, testingPublicKey, err = ca.GenSecp256k1KeyPair(); err != nil { |
| 221 | panic(err) |
| 222 | } |
| 223 | kms.Unittest = true |
| 224 | kms.SetLocalKeyPair(testingPrivateKey, testingPublicKey) |
| 225 | if err = kms.SavePrivateKey( |
| 226 | testingPrivateKeyFile, testingPrivateKey, testingMasterKey, |
| 227 | ); err != nil { |
| 228 | panic(err) |
| 229 | } |
| 230 | |
| 231 | log.SetLevel(log.DebugLevel) |
| 232 | log.SetOutput(os.Stdout) |
| 233 | } |
| 234 | |
| 235 | func teardown() { |
| 236 | //trace.Stop() |
no test coverage detected