MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / createRandomBlock

Function createRandomBlock

sqlchain/xxx_test.go:248–278  ·  view source on GitHub ↗
(parent hash.Hash, isGenesis bool)

Source from the content-addressed store, hash-verified

246}
247
248func createRandomBlock(parent hash.Hash, isGenesis bool) (b *types.Block, err error) {
249 b, err = types.CreateRandomBlock(parent, isGenesis)
250 if err != nil {
251 return
252 }
253
254 if isGenesis {
255 return
256 }
257
258 // Generate key pair
259 priv, _, err := asymmetric.GenSecp256k1KeyPair()
260 if err != nil {
261 return
262 }
263
264 for i, n := 0, rand.Intn(10)+10; i < n; i++ {
265 h := &hash.Hash{}
266 rand.Read(h[:])
267 b.Acks = []*types.SignedAckHeader{
268 {
269 DefaultHashSignVerifierImpl: verifier.DefaultHashSignVerifierImpl{
270 DataHash: *h,
271 },
272 },
273 }
274 }
275
276 err = b.PackAndSignBlock(priv)
277 return
278}
279
280func createTestPeers(num int) (nis []cpuminer.NonceInfo, p *proto.Peers, err error) {
281 if num <= 0 {

Callers 3

TestIndexKeyFunction · 0.85
TestMultiChainFunction · 0.85
generateTestBlocksFunction · 0.85

Calls 4

CreateRandomBlockFunction · 0.92
GenSecp256k1KeyPairFunction · 0.92
ReadMethod · 0.65
PackAndSignBlockMethod · 0.45

Tested by

no test coverage detected