Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different block in TestBlockFetcher_GetBlock_and_SubscribeNewBlockEvent #683

Closed
adlerjohn opened this issue May 6, 2022 · 3 comments · Fixed by #756
Closed

Different block in TestBlockFetcher_GetBlock_and_SubscribeNewBlockEvent #683

adlerjohn opened this issue May 6, 2022 · 3 comments · Fixed by #756
Labels
bug Something isn't working good first issue Good for newcomers kind:testing Related to unit tests

Comments

@adlerjohn
Copy link
Member

adlerjohn commented May 6, 2022

Celestia Node version

76b969fe7d5115ddcc5436ca10641b3d12855825

OS

NAME="Ubuntu"
VERSION="20.04.4 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.4 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

Install tools

No response

Others

No response

Steps to reproduce it

make test-unit a few times

Expected result

PASS

Actual result

=== RUN   TestBlockFetcher_GetBlock_and_SubscribeNewBlockEvent
    fetcher_test.go:30: 
        	Error Trace:	fetcher_test.go:30
        	Error:      	Not equal: 
        	            	expected: &types.Block{mtx:sync.Mutex{Mutex:sync.Mutex{state:0, sema:0x0}}, Header:types.Header{Version:version.Consensus{Block:0xb, App:0x1}, ChainID:"tendermint_test", Height:1, Time:time.Date(2018, time.October, 10, 8, 20, 13, 695936996, time.UTC), LastBlockID:types.BlockID{Hash:, PartSetHeader:types.PartSetHeader{Total:0x0, Hash:}}, LastCommitHash:E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855, DataHash:7B578B351B1B0BBD70BB350019EBC964C44A140A37EF715B552A7F8F315ACD19, ValidatorsHash:8C591E1C1B36B19BD29F16971023819E0C2CCAF634CDAA81ECDD30337DCC078D, NextValidatorsHash:8C591E1C1B36B19BD29F16971023819E0C2CCAF634CDAA81ECDD30337DCC078D, ConsensusHash:048091BC7DDC283F77BFBF91D73C44DA58C3DF8A9CBC867405D8B7F3DAADA22F, AppHash:, LastResultsHash:E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855, EvidenceHash:E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855, ProposerAddress:A3258DCBF45DCA0DF052981870F2D1441A36D145}, Data:types.Data{Txs:types.Txs(nil), Evidence:types.EvidenceData{Evidence:types.EvidenceList(nil), hash:bytes.HexBytes(nil), byteSize:0}, Messages:types.Messages{MessagesList:[]types.Message(nil)}, OriginalSquareSize:0x1, hash:bytes.HexBytes(nil)}, LastCommit:(*types.Commit)(0xc000147a80)}
        	            	actual  : &types.Block{mtx:sync.Mutex{Mutex:sync.Mutex{state:0, sema:0x0}}, Header:types.Header{Version:version.Consensus{Block:0xb, App:0x1}, ChainID:"tendermint_test", Height:2, Time:time.Date(2022, time.May, 6, 13, 31, 33, 116109611, time.UTC), LastBlockID:types.BlockID{Hash:BCFA00ABBD425398D71C1F0EDF7220ECCBEE87ACB4C36F92DCD92D77C6581A1F, PartSetHeader:types.PartSetHeader{Total:0x1, Hash:B634C42794533835E51BF1AA00415ED1FFA0DB8650BEF162F0E8D57DF8A3DCB3}}, LastCommitHash:51D07C2AA4829E3CE5B0A13AAD432E4FE05C9BC355457E689EEE27784BA0345B, DataHash:7B578B351B1B0BBD70BB350019EBC964C44A140A37EF715B552A7F8F315ACD19, ValidatorsHash:8C591E1C1B36B19BD29F16971023819E0C2CCAF634CDAA81ECDD30337DCC078D, NextValidatorsHash:8C591E1C1B36B19BD29F16971023819E0C2CCAF634CDAA81ECDD30337DCC078D, ConsensusHash:048091BC7DDC283F77BFBF91D73C44DA58C3DF8A9CBC867405D8B7F3DAADA22F, AppHash:0000000000000000, LastResultsHash:E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855, EvidenceHash:E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855, ProposerAddress:A3258DCBF45DCA0DF052981870F2D1441A36D145}, Data:types.Data{Txs:types.Txs(nil), Evidence:types.EvidenceData{Evidence:types.EvidenceList(nil), hash:bytes.HexBytes(nil), byteSize:0}, Messages:types.Messages{MessagesList:[]types.Message(nil)}, OriginalSquareSize:0x1, hash:bytes.HexBytes(nil)}, LastCommit:(*types.Commit)(0xc000430700)}
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -13,6 +13,6 @@
        	            	   ChainID: (string) (len=15) "tendermint_test",
        	            	-  Height: (int64) 1,
        	            	+  Height: (int64) 2,
        	            	   Time: (time.Time) {
        	            	-   wall: (uint64) 695936996,
        	            	-   ext: (int64) 63674756413,
        	            	+   wall: (uint64) 116109611,
        	            	+   ext: (int64) 63787440693,
        	            	    loc: (*time.Location)(<nil>)
        	            	@@ -20,7 +20,11 @@
        	            	   LastBlockID: (types.BlockID) {
        	            	-   Hash: (bytes.HexBytes) {
        	            	+   Hash: (bytes.HexBytes) (len=32) {
        	            	+    00000000  bc fa 00 ab bd 42 53 98  d7 1c 1f 0e df 72 20 ec  |.....BS......r .|
        	            	+    00000010  cb ee 87 ac b4 c3 6f 92  dc d9 2d 77 c6 58 1a 1f  |......o...-w.X..|
        	            	    },
        	            	    PartSetHeader: (types.PartSetHeader) {
        	            	-    Total: (uint32) 0,
        	            	-    Hash: (bytes.HexBytes) {
        	            	+    Total: (uint32) 1,
        	            	+    Hash: (bytes.HexBytes) (len=32) {
        	            	+     00000000  b6 34 c4 27 94 53 38 35  e5 1b f1 aa 00 41 5e d1  |.4.'.S85.....A^.|
        	            	+     00000010  ff a0 db 86 50 be f1 62  f0 e8 d5 7d f8 a3 dc b3  |....P..b...}....|
        	            	     }
        	            	@@ -29,4 +33,4 @@
        	            	   LastCommitHash: (bytes.HexBytes) (len=32) {
        	            	-   00000000  e3 b0 c4 42 98 fc 1c 14  9a fb f4 c8 99 6f b9 24  |...B.........o.$|
        	            	-   00000010  27 ae 41 e4 64 9b 93 4c  a4 95 99 1b 78 52 b8 55  |'.A.d..L....xR.U|
        	            	+   00000000  51 d0 7c 2a a4 82 9e 3c  e5 b0 a1 3a ad 43 2e 4f  |Q.|*...<...:.C.O|
        	            	+   00000010  e0 5c 9b c3 55 45 7e 68  9e ee 27 78 4b a0 34 5b  |.\..UE~h..'xK.4[|
        	            	   },
        	            	@@ -48,3 +52,4 @@
        	            	   },
        	            	-  AppHash: (bytes.HexBytes) {
        	            	+  AppHash: (bytes.HexBytes) (len=8) {
        	            	+   00000000  00 00 00 00 00 00 00 00                           |........|
        	            	   },
        	            	@@ -77,10 +82,14 @@
        	            	  LastCommit: (*types.Commit)({
        	            	-  Height: (int64) 0,
        	            	+  Height: (int64) 1,
        	            	   Round: (int32) 0,
        	            	   BlockID: (types.BlockID) {
        	            	-   Hash: (bytes.HexBytes) {
        	            	+   Hash: (bytes.HexBytes) (len=32) {
        	            	+    00000000  bc fa 00 ab bd 42 53 98  d7 1c 1f 0e df 72 20 ec  |.....BS......r .|
        	            	+    00000010  cb ee 87 ac b4 c3 6f 92  dc d9 2d 77 c6 58 1a 1f  |......o...-w.X..|
        	            	    },
        	            	    PartSetHeader: (types.PartSetHeader) {
        	            	-    Total: (uint32) 0,
        	            	-    Hash: (bytes.HexBytes) {
        	            	+    Total: (uint32) 1,
        	            	+    Hash: (bytes.HexBytes) (len=32) {
        	            	+     00000000  b6 34 c4 27 94 53 38 35  e5 1b f1 aa 00 41 5e d1  |.4.'.S85.....A^.|
        	            	+     00000010  ff a0 db 86 50 be f1 62  f0 e8 d5 7d f8 a3 dc b3  |....P..b...}....|
        	            	     }
        	            	@@ -88,3 +97,22 @@
        	            	   },
        	            	-  Signatures: ([]types.CommitSig) <nil>,
        	            	+  Signatures: ([]types.CommitSig) (len=1) {
        	            	+   (types.CommitSig) {
        	            	+    BlockIDFlag: (types.BlockIDFlag) 2,
        	            	+    ValidatorAddress: (bytes.HexBytes) (len=20) {
        	            	+     00000000  a3 25 8d cb f4 5d ca 0d  f0 52 98 18 70 f2 d1 44  |.%...]...R..p..D|
        	            	+     00000010  1a 36 d1 45                                       |.6.E|
        	            	+    },
        	            	+    Timestamp: (time.Time) {
        	            	+     wall: (uint64) 116109611,
        	            	+     ext: (int64) 63787440693,
        	            	+     loc: (*time.Location)(<nil>)
        	            	+    },
        	            	+    Signature: ([]uint8) (len=64) {
        	            	+     00000000  6f e0 02 8b 37 63 29 4a  1d 35 8f 04 2a 48 31 a3  |o...7c)J.5..*H1.|
        	            	+     00000010  d7 b8 14 a6 3f a0 69 35  91 be b7 2b a6 2b 5a 97  |....?.i5...+.+Z.|
        	            	+     00000020  d3 5b 92 ef 60 d8 f2 cb  df f6 ff bf 21 ea 07 42  |.[..`.......!..B|
        	            	+     00000030  ec 00 65 6e a8 ee b4 e6  5f d9 f4 d0 f3 2e 07 0b  |..en...._.......|
        	            	+    }
        	            	+   }
        	            	+  },
        	            	   hash: (bytes.HexBytes) <nil>,
        	Test:       	TestBlockFetcher_GetBlock_and_SubscribeNewBlockEvent
--- FAIL: TestBlockFetcher_GetBlock_and_SubscribeNewBlockEvent (0.04s)

Relevant log output

No response

Notes

No response

@adlerjohn adlerjohn added bug Something isn't working kind:testing Related to unit tests labels May 6, 2022
@Wondertan
Copy link
Member

It's a flakey one. Sometimes Tedermint starts from the height 2 for some unapparent reason. There are also other tests that sometimes failing for the same reason

@tzdybal
Copy link
Member

tzdybal commented May 8, 2022

Tests are querying for latest block, and sometimes multiple blocks are generated before test requests "latest" - it seems that test assumes that to much about blocking nature of newBlockChan.

One way to make this test stable is to get block at given height, like:
block, err := fetcher.GetBlock(ctx, &newBlockFromChan.Height).

I need to find a local branch where I experimented with this.

@Wondertan
Copy link
Member

Yeah, this should fix the issue

block, err := fetcher.GetBlock(ctx, &newBlockFromChan.Height).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers kind:testing Related to unit tests
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants