github.com/bytom/bytom@v1.1.2-0.20221014091027-bbcba3df6075/consensus/server_flag_test.go (about) 1 package consensus 2 3 import "testing" 4 5 func TestIsEnable(t *testing.T) { 6 cases := []struct { 7 baseFlag ServiceFlag 8 checkFlage ServiceFlag 9 result bool 10 }{ 11 { 12 baseFlag: SFFullNode, 13 checkFlage: SFFullNode, 14 result: true, 15 }, 16 { 17 baseFlag: SFFullNode, 18 checkFlage: SFFastSync, 19 result: false, 20 }, 21 { 22 baseFlag: SFFullNode | SFFastSync, 23 checkFlage: SFFullNode, 24 result: true, 25 }, 26 { 27 baseFlag: SFFullNode | SFFastSync, 28 checkFlage: SFFastSync, 29 result: true, 30 }, 31 } 32 33 for i, c := range cases { 34 if c.baseFlag.IsEnable(c.checkFlage) != c.result { 35 t.Errorf("test case #%d got %t, want %t", i, c.baseFlag.IsEnable(c.checkFlage), c.result) 36 } 37 } 38 }