// Check the expected values of a contract against the contract's values in the tree.
// Also, compare the contract's code in the tree against the actual contract code file.
Check the expected values of a contract against the contract's values in the tree.
Also, compare the contract's code in the tree against the actual contract code file.
// Check the expected values of a contract against the contract ' s values in the tree . // Also compare the contract ' s code in the tree against the actual contract code file .
func checkContract(t *testing.T, tree *avl.Tree, id TransactionID, codeFilePath string, expectedGasBalance uint64, expectedEmptyMemPages []int, expectedNotEmptyMemPages []int) {
	code, exist := ReadAccountContractCode(tree, id)
	assert.True(t, exist, "contract ID: %x", id)
	assert.NotEmpty(t, code, "contract ID: %x", id)
	gasBalance, exist := ReadAccountContractGasBalance(tree, id)
	assert.True(t, exist, "contract ID: %x", id)
	assert.Equal(t, expectedGasBalance, gasBalance, "contract ID: %x", id)
	expectedCode, err := ioutil.ReadFile(codeFilePath)
	assert.NoError(t, err)
	assert.EqualValues(t, expectedCode, code, "contract ID: %x, filepath: %s", id, codeFilePath)
	numPages, exist := ReadAccountContractNumPages(tree, id)
	assert.True(t, exist, "contract ID: %x", id)
	assert.EqualValues(t, expectedPageNum, numPages, "contract ID: %x", id)
	for _, v := range expectedEmptyMemPages {
		page, exist := ReadAccountContractPage(tree, id, uint64(v))
		assert.False(t, exist)
		assert.Empty(t, page)
	}
	for _, v := range expectedNotEmptyMemPages {
		page, exist := ReadAccountContractPage(tree, id, uint64(v))
		assert.True(t, exist)
		assert.NotEmpty(t, page)
		assert.Len(t, page, PageSize)
	}
}
func checkContract ( t * testing . T , tree * avl . Tree , id TransactionID , codeFilePath string , expectedGasBalance uint64 , expectedEmptyMemPages [ ] int , expectedNotEmptyMemPages [ ] int ) { code , exist := ReadAccountContractCode ( tree , id ) assert . True ( t , exist , " " , id ) assert . NotEmpty ( t , code , " " , id ) gasBalance , exist := ReadAccountContractGasBalance ( tree , id ) assert . True ( t , exist , " " , id ) assert . Equal ( t , expectedGasBalance , gasBalance , " " , id ) expectedCode , err := ioutil . ReadFile ( codeFilePath ) assert . NoError ( t , err ) assert . EqualValues ( t , expectedCode , code , " " , id , codeFilePath ) numPages , exist := ReadAccountContractNumPages ( tree , id ) assert . True ( t , exist , " " , id ) assert . EqualValues ( t , expectedPageNum , numPages , " " , id ) for _ , v := range expectedEmptyMemPages { page , exist := ReadAccountContractPage ( tree , id , uint64 ( v ) ) assert . False ( t , exist ) assert . Empty ( t , page ) } for _ , v := range expectedNotEmptyMemPages { page , exist := ReadAccountContractPage ( tree , id , uint64 ( v ) ) assert . True ( t , exist ) assert . NotEmpty ( t , page ) assert . Len ( t , page , PageSize ) } }
Check the expected values of a contract against the contract's values in the tree.
Check the expected values of a contract against the contract ' s values in the tree .