(t *testing.T)
| 49 | } |
| 50 | |
| 51 | func TestGetNextPuzzle(t *testing.T) { |
| 52 | var totalRecordsInSQLChain int32 = 10 |
| 53 | index, err := getNextPuzzle(answers, previousBlock) |
| 54 | if err != nil { |
| 55 | t.Error(err) |
| 56 | } |
| 57 | var wantedIndex int32 |
| 58 | for _, answer := range answers { |
| 59 | wantedIndex += int32(hash.FNVHash32uint(answer.Answer[:])) |
| 60 | } |
| 61 | wantedIndex += int32(hash.FNVHash32uint([]byte(previousBlock.ID))) |
| 62 | wantedIndex %= totalRecordsInSQLChain |
| 63 | if index != wantedIndex { |
| 64 | t.Errorf("the next sql index is %+v, should be %+v. "+ |
| 65 | "Answers are %+v, and the previous block is %+v", |
| 66 | index, wantedIndex, answers, previousBlock) |
| 67 | } |
| 68 | |
| 69 | // void answer |
| 70 | index, err = getNextPuzzle(voidAnswer, previousBlock) |
| 71 | if err == nil { |
| 72 | t.Errorf("index is %d, but should be failed", index) |
| 73 | } |
| 74 | |
| 75 | // void block |
| 76 | index, err = getNextPuzzle(answers, voidBlock) |
| 77 | if err == nil { |
| 78 | t.Errorf("index is %d, but should be failed", index) |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | func TestGetNextVerifier(t *testing.T) { |
| 83 | verifier, err := getNextVerifier(previousBlock, currentBlock) |
nothing calls this directly
no test coverage detected