@@ -58,13 +58,27 @@ class ErgoStateContextSpec extends HistoryTestHelpers {
58
58
fb.copy(extension = newExtension)
59
59
}
60
60
61
+ // regression stress-test for sporadic failure https://github.com/ergoplatform/ergo/issues/2114
62
+ // disabling for now
63
+ // for (i <- 1 to 1000) {
64
+ // printf("\r%d05 ", i)
65
+
61
66
// checks, specific for extension
62
67
// validation of field keys size
63
68
val imvKey = extensionKvGen(Extension .FieldKeySize - 1 , Extension .FieldValueMaxSize ).sample.get
64
69
sc.appendFullBlock(fbWithFields(imvKey +: oldFields)) shouldBe ' failure
65
70
71
+ // https://github.com/ergoplatform/ergo/issues/2114
72
+ // this fails sporadically, when `(imvValue._1.head == 0)`, because less value bytes will be generated
73
+ // by extensionKvGen(). Workaround is to just generate again while `(imvValue._1.head == 0)`
74
+ // TODO: document, and possibly rewrite extensionKvGen after the above issues are clarified/solved
75
+ // https://github.com/ergoplatform/ergo/issues/2118
76
+
66
77
// validation of field value sizes
67
- val imvValue = extensionKvGen(Extension .FieldKeySize , Extension .FieldValueMaxSize + 1 ).sample.get
78
+ var imvValue = extensionKvGen(Extension .FieldKeySize , Extension .FieldValueMaxSize + 1 ).sample.get
79
+ while (imvValue._1.head == 0 ) {
80
+ imvValue = extensionKvGen(Extension .FieldKeySize , Extension .FieldValueMaxSize + 1 ).sample.get
81
+ }
68
82
sc.appendFullBlock(fbWithFields(imvValue +: oldFields)) shouldBe ' failure
69
83
70
84
// validation of incorrect interlinks
@@ -73,13 +87,23 @@ class ErgoStateContextSpec extends HistoryTestHelpers {
73
87
).fields
74
88
sc.appendFullBlock(fbWithFields(invalidInterlinks ++ oldFields)) shouldBe ' failure
75
89
90
+ // https://github.com/ergoplatform/ergo/issues/2114
91
+ // if validMKV._1.head is 1, appendFullBlock within "valid application of correct extension" will fail
92
+ // As a workaround, just generate new values until (validMKV._1.head != 1)
93
+ // TODO: investigate and provide a full fix (followup issue)
94
+ // https://github.com/ergoplatform/ergo/issues/2117
95
+ var validMKV = extensionKvGen(Extension .FieldKeySize , Extension .FieldValueMaxSize ).sample.get
96
+ while (validMKV._1.head == 1 ) {
97
+ validMKV = extensionKvGen(Extension .FieldKeySize , Extension .FieldValueMaxSize ).sample.get
98
+ }
76
99
// validation of key duplicates in fields
77
- val validMKV = extensionKvGen(Extension .FieldKeySize , Extension .FieldValueMaxSize ).sample.get
78
100
sc.appendFullBlock(fbWithFields(Seq (validMKV, validMKV) ++ oldFields)) shouldBe ' failure
79
101
80
102
// valid application of correct extension
81
103
sc.appendFullBlock(fbWithFields(validMKV +: oldFields)) shouldBe ' success
82
104
83
- }
105
+ }
106
+
107
+ // } // test-loop
84
108
85
109
}
0 commit comments