github.com/sberex/go-sberex@v1.8.2-0.20181113200658-ed96ac38f7d7/consensus/ethash/algorithm_go1.8_test.go (about)

     1  // This file is part of the go-sberex library. The go-sberex library is 
     2  // free software: you can redistribute it and/or modify it under the terms 
     3  // of the GNU Lesser General Public License as published by the Free 
     4  // Software Foundation, either version 3 of the License, or (at your option)
     5  // any later version.
     6  //
     7  // The go-sberex library is distributed in the hope that it will be useful, 
     8  // but WITHOUT ANY WARRANTY; without even the implied warranty of
     9  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 
    10  // General Public License <http://www.gnu.org/licenses/> for more details.
    11  
    12  // +build go1.8
    13  
    14  package ethash
    15  
    16  import "testing"
    17  
    18  // Tests whether the dataset size calculator works correctly by cross checking the
    19  // hard coded lookup table with the value generated by it.
    20  func TestSizeCalculations(t *testing.T) {
    21  	// Verify all the cache and dataset sizes from the lookup table.
    22  	for epoch, want := range cacheSizes {
    23  		if size := calcCacheSize(epoch); size != want {
    24  			t.Errorf("cache %d: cache size mismatch: have %d, want %d", epoch, size, want)
    25  		}
    26  	}
    27  	for epoch, want := range datasetSizes {
    28  		if size := calcDatasetSize(epoch); size != want {
    29  			t.Errorf("dataset %d: dataset size mismatch: have %d, want %d", epoch, size, want)
    30  		}
    31  	}
    32  }