Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • hive/haf
  • dan/haf
2 results
Show changes
Commits on Source (2)
......@@ -33,6 +33,7 @@ ADD_PSQL_EXTENSION(
blocks_views_for_contexts.sql
get_keyauths.sql
get_metadata.sql
get_vesting_balance.sql
state_providers/accounts.sql
state_providers/keyauth.sql
state_providers/metadata.sql
......
CREATE OR REPLACE FUNCTION hive.get_vesting_balance(_block_num INT, _current_vesting_shares BIGINT)
RETURNS numeric
LANGUAGE plpgsql
STABLE
AS
$BODY$
DECLARE
__total_vesting_shares numeric;
__total_vesting_fund_hive numeric;
__hp BIGINT;
BEGIN
SELECT total_vesting_shares, total_vesting_fund_hive
INTO __total_vesting_shares, __total_vesting_fund_hive
FROM hive.blocks WHERE num= _block_num;
__hp := (_current_vesting_shares * __total_vesting_fund_hive) / NULLIF(__total_vesting_shares, 0);
RETURN __hp;
END;
$BODY$
;
......@@ -287,6 +287,9 @@ ENDMACRO()
ADD_SQL_FUNCTIONAL_TEST( shared_lib/extract_set_witness_properties.sql )
ADD_SQL_FUNCTIONAL_TEST( shared_lib/operation_to_jsonb_conversion.sql )
ADD_SQL_FUNCTIONAL_TEST( shared_lib/calculate_schema_hash.sql )
ADD_SQL_FUNCTIONAL_TEST( shared_lib/get_vesting_balance/get_vesting_balance.sql )
ADD_SQL_FUNCTIONAL_TEST( sanity_check/test_tables_and_sequences_properly_flagged_for_dump.sql )
DROP FUNCTION IF EXISTS haf_admin_test_given;
CREATE FUNCTION haf_admin_test_given()
RETURNS void
LANGUAGE 'plpgsql'
VOLATILE
AS
$BODY$
BEGIN
INSERT INTO hive.blocks
VALUES
( 1, '\xBADD10', '\xCAFE10', '2016-06-22 19:10:21-07'::timestamp, 5, '\x4007', E'[]', '\x2157', 'STM65w', 1000, 312785920, 5435823, 1000, 1000, 1000, 2000, 2000 )
, ( 2, '\xBADD20', '\xCAFE20', '2016-06-22 19:10:24-07'::timestamp, 5, '\x4007', E'[]', '\x2157', 'STM65w', 1000, 312785920, 0, 1000, 1000, 1000, 2000, 2000 )
;
INSERT INTO hive.accounts( id, name, block_num )
VALUES (5, 'initminer', 1)
;
END;
$BODY$
;
DROP FUNCTION IF EXISTS haf_admin_test_then;
CREATE FUNCTION haf_admin_test_then()
RETURNS void
LANGUAGE 'plpgsql'
STABLE
AS
$BODY$
BEGIN
ASSERT (SELECT hive.get_vesting_balance(1, 12312213124132120)) = 708464368554262962, 'Results do not match';
ASSERT (SELECT hive.get_vesting_balance(2, 12312312412)) IS NULL, 'Function did not return NULL';
END;
$BODY$
;