feat: update

This commit is contained in:
georgehao
2024-04-20 22:09:35 +08:00
parent fa813dbfc4
commit 609a4b92e5

View File

@@ -565,7 +565,7 @@ func testValidProof(t *testing.T) {
assert.NoError(t, err)
// create mock provers.
provers := make([]*mockProver, 2)
provers := make([]*mockProver, 1)
for i := 0; i < len(provers); i++ {
var proofType message.ProofType
if i%2 == 0 {
@@ -584,47 +584,47 @@ func testValidProof(t *testing.T) {
provers[i].submitProof(t, proverTask, proofStatus, types.Success, "istanbul")
}
// verify proof status
var (
tick = time.Tick(1500 * time.Millisecond)
tickStop = time.Tick(time.Minute)
)
var (
chunkProofStatus types.ProvingStatus
batchProofStatus types.ProvingStatus
chunkActiveAttempts int16
chunkMaxAttempts int16
batchActiveAttempts int16
batchMaxAttempts int16
)
for {
select {
case <-tick:
chunkProofStatus, err = chunkOrm.GetProvingStatusByHash(context.Background(), dbChunk.Hash)
assert.NoError(t, err)
batchProofStatus, err = batchOrm.GetProvingStatusByHash(context.Background(), batch.Hash)
assert.NoError(t, err)
if chunkProofStatus == types.ProvingTaskVerified && batchProofStatus == types.ProvingTaskVerified {
return
}
chunkActiveAttempts, chunkMaxAttempts, err = chunkOrm.GetAttemptsByHash(context.Background(), dbChunk.Hash)
assert.NoError(t, err)
assert.Equal(t, 1, int(chunkMaxAttempts))
assert.Equal(t, 0, int(chunkActiveAttempts))
batchActiveAttempts, batchMaxAttempts, err = batchOrm.GetAttemptsByHash(context.Background(), batch.Hash)
assert.NoError(t, err)
assert.Equal(t, 1, int(batchMaxAttempts))
assert.Equal(t, 0, int(batchActiveAttempts))
case <-tickStop:
t.Error("failed to check proof status", "chunkProofStatus", chunkProofStatus.String(), "batchProofStatus", batchProofStatus.String())
return
}
}
//// verify proof status
//var (
// tick = time.Tick(1500 * time.Millisecond)
// tickStop = time.Tick(time.Minute)
//)
//
//var (
// chunkProofStatus types.ProvingStatus
// batchProofStatus types.ProvingStatus
// chunkActiveAttempts int16
// chunkMaxAttempts int16
// batchActiveAttempts int16
// batchMaxAttempts int16
//)
//
//for {
// select {
// case <-tick:
// chunkProofStatus, err = chunkOrm.GetProvingStatusByHash(context.Background(), dbChunk.Hash)
// assert.NoError(t, err)
// batchProofStatus, err = batchOrm.GetProvingStatusByHash(context.Background(), batch.Hash)
// assert.NoError(t, err)
// if chunkProofStatus == types.ProvingTaskVerified && batchProofStatus == types.ProvingTaskVerified {
// return
// }
//
// chunkActiveAttempts, chunkMaxAttempts, err = chunkOrm.GetAttemptsByHash(context.Background(), dbChunk.Hash)
// assert.NoError(t, err)
// assert.Equal(t, 1, int(chunkMaxAttempts))
// assert.Equal(t, 0, int(chunkActiveAttempts))
//
// batchActiveAttempts, batchMaxAttempts, err = batchOrm.GetAttemptsByHash(context.Background(), batch.Hash)
// assert.NoError(t, err)
// assert.Equal(t, 1, int(batchMaxAttempts))
// assert.Equal(t, 0, int(batchActiveAttempts))
//
// case <-tickStop:
// t.Error("failed to check proof status", "chunkProofStatus", chunkProofStatus.String(), "batchProofStatus", batchProofStatus.String())
// return
// }
//}
}
func testInvalidProof(t *testing.T) {